@lifi/sdk 4.0.0-beta.6 → 4.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/actions/getChains.js.map +1 -1
- package/dist/cjs/actions/getConnections.js.map +1 -1
- package/dist/cjs/actions/getContractCallsQuote.js.map +1 -1
- package/dist/cjs/actions/getNameServiceAddress.js.map +1 -1
- package/dist/cjs/actions/getQuote.js.map +1 -1
- package/dist/cjs/actions/getRelayedTransactionStatus.js +2 -2
- package/dist/cjs/actions/getRelayedTransactionStatus.js.map +1 -1
- package/dist/cjs/actions/getRelayerQuote.js +2 -2
- package/dist/cjs/actions/getRelayerQuote.js.map +1 -1
- package/dist/cjs/actions/getTokenBalances.js.map +1 -1
- package/dist/cjs/actions/getTokenBalancesByChain.js.map +1 -1
- package/dist/cjs/actions/getTokens.js.map +1 -1
- package/dist/cjs/actions/getWalletBalances.js.map +1 -1
- package/dist/cjs/actions/relayTransaction.js +2 -2
- package/dist/cjs/actions/relayTransaction.js.map +1 -1
- package/dist/cjs/client/createClient.js.map +1 -1
- package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
- package/dist/cjs/core/StatusManager.js.map +1 -1
- package/dist/cjs/core/TaskPipeline.js.map +1 -1
- package/dist/cjs/core/execution.js +2 -2
- package/dist/cjs/core/execution.js.map +1 -1
- package/dist/cjs/core/tasks/CheckBalanceTask.d.ts +9 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.js +13 -3
- package/dist/cjs/core/tasks/CheckBalanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/PrepareTransactionTask.js +3 -3
- package/dist/cjs/core/tasks/PrepareTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +2 -2
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/checkBalance.d.ts +12 -2
- package/dist/cjs/core/tasks/helpers/checkBalance.js +19 -12
- package/dist/cjs/core/tasks/helpers/checkBalance.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js +3 -3
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/stepComparison.js +2 -2
- package/dist/cjs/core/tasks/helpers/stepComparison.js.map +1 -1
- package/dist/cjs/core/utils.js.map +1 -1
- package/dist/cjs/errors/errors.js +9 -9
- package/dist/cjs/errors/errors.js.map +1 -1
- package/dist/cjs/errors/httpError.js +17 -17
- package/dist/cjs/errors/httpError.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/types/core.d.ts +0 -4
- package/dist/cjs/utils/checkPackageUpdates.js +1 -1
- package/dist/cjs/utils/checkPackageUpdates.js.map +1 -1
- package/dist/cjs/utils/convertQuoteToRoute.js.map +1 -1
- package/dist/cjs/utils/decode.js.map +1 -1
- package/dist/cjs/utils/fetchTxErrorDetails.js.map +1 -1
- package/dist/cjs/utils/getTransactionMessage.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/getChains.js.map +1 -1
- package/dist/esm/actions/getConnections.js.map +1 -1
- package/dist/esm/actions/getContractCallsQuote.js.map +1 -1
- package/dist/esm/actions/getNameServiceAddress.js.map +1 -1
- package/dist/esm/actions/getQuote.js.map +1 -1
- package/dist/esm/actions/getRelayedTransactionStatus.js +2 -2
- package/dist/esm/actions/getRelayedTransactionStatus.js.map +1 -1
- package/dist/esm/actions/getRelayerQuote.js +2 -2
- package/dist/esm/actions/getRelayerQuote.js.map +1 -1
- package/dist/esm/actions/getTokenBalances.js.map +1 -1
- package/dist/esm/actions/getTokenBalancesByChain.js.map +1 -1
- package/dist/esm/actions/getTokens.js.map +1 -1
- package/dist/esm/actions/getWalletBalances.js.map +1 -1
- package/dist/esm/actions/relayTransaction.js +2 -2
- package/dist/esm/actions/relayTransaction.js.map +1 -1
- package/dist/esm/client/createClient.js.map +1 -1
- package/dist/esm/core/BaseStepExecutor.js.map +1 -1
- package/dist/esm/core/StatusManager.js.map +1 -1
- package/dist/esm/core/TaskPipeline.js.map +1 -1
- package/dist/esm/core/execution.js +2 -2
- package/dist/esm/core/execution.js.map +1 -1
- package/dist/esm/core/tasks/CheckBalanceTask.d.ts +9 -0
- package/dist/esm/core/tasks/CheckBalanceTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/CheckBalanceTask.js +13 -3
- package/dist/esm/core/tasks/CheckBalanceTask.js.map +1 -1
- package/dist/esm/core/tasks/PrepareTransactionTask.js +3 -3
- package/dist/esm/core/tasks/PrepareTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +2 -3
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
- package/dist/esm/core/tasks/helpers/checkBalance.d.ts +12 -2
- package/dist/esm/core/tasks/helpers/checkBalance.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/checkBalance.js +19 -12
- package/dist/esm/core/tasks/helpers/checkBalance.js.map +1 -1
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.js +3 -3
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.js.map +1 -1
- package/dist/esm/core/tasks/helpers/stepComparison.js +2 -2
- package/dist/esm/core/tasks/helpers/stepComparison.js.map +1 -1
- package/dist/esm/core/utils.js.map +1 -1
- package/dist/esm/errors/errors.js +9 -9
- package/dist/esm/errors/errors.js.map +1 -1
- package/dist/esm/errors/httpError.js +17 -17
- package/dist/esm/errors/httpError.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/types/core.d.ts +0 -4
- package/dist/esm/types/core.d.ts.map +1 -1
- package/dist/esm/utils/checkPackageUpdates.js +1 -1
- package/dist/esm/utils/checkPackageUpdates.js.map +1 -1
- package/dist/esm/utils/convertQuoteToRoute.js.map +1 -1
- package/dist/esm/utils/decode.js.map +1 -1
- package/dist/esm/utils/fetchTxErrorDetails.js.map +1 -1
- package/dist/esm/utils/getTransactionMessage.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +2 -2
- package/src/core/tasks/CheckBalanceTask.ts +19 -2
- package/src/core/tasks/helpers/checkBalance.ts +53 -21
- package/src/index.ts +4 -1
- package/src/types/core.ts +0 -4
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getChains.js","names":["withDedupe","request"],"sources":["../../../src/actions/getChains.ts"],"sourcesContent":["import type {\n ChainsRequest,\n ChainsResponse,\n ExtendedChain,\n RequestOptions,\n} from '@lifi/types'\nimport type { SDKBaseConfig, SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { withDedupe } from '../utils/withDedupe.js'\n\n/**\n * Get all available chains\n * @param client - The SDK client\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n * @throws {LiFiError} Throws a LiFiError if request fails.\n */\nexport const getChains = async (\n client: SDKClient,\n params?: ChainsRequest,\n options?: RequestOptions\n): Promise<ExtendedChain[]> => {\n return await _getChains(client.config, params, options)\n}\n\nexport const _getChains = async (\n config: SDKBaseConfig,\n params?: ChainsRequest,\n options?: RequestOptions\n): Promise<ExtendedChain[]> => {\n if (params) {\n for (const key of Object.keys(params)) {\n const value = params[key as keyof ChainsRequest]\n if (value === undefined || value === null) {\n delete params[key as keyof ChainsRequest]\n }\n }\n }\n const urlSearchParams = new URLSearchParams(\n params as Record<string, string>\n ).toString()\n const response = await withDedupe(\n () =>\n request<ChainsResponse>(\n config,\n `${config.apiUrl}/chains?${urlSearchParams}`,\n {\n signal: options?.signal,\n }\n ),\n { id: `${getChains.name}.${urlSearchParams}` }\n )\n return response.chains\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,YAAY,OACvB,QACA,QACA,YAC6B;AAC7B,QAAO,MAAM,WAAW,OAAO,QAAQ,QAAQ,QAAQ;;AAGzD,MAAa,aAAa,OACxB,QACA,QACA,YAC6B;AAC7B,KAAI,OACF,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;EACrC,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,KAAA,KAAa,UAAU,KACnC,QAAO,OAAO;;CAIpB,MAAM,kBAAkB,IAAI,gBAC1B,OACD,CAAC,UAAU;AAYZ,
|
|
1
|
+
{"version":3,"file":"getChains.js","names":["withDedupe","request"],"sources":["../../../src/actions/getChains.ts"],"sourcesContent":["import type {\n ChainsRequest,\n ChainsResponse,\n ExtendedChain,\n RequestOptions,\n} from '@lifi/types'\nimport type { SDKBaseConfig, SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { withDedupe } from '../utils/withDedupe.js'\n\n/**\n * Get all available chains\n * @param client - The SDK client\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n * @throws {LiFiError} Throws a LiFiError if request fails.\n */\nexport const getChains = async (\n client: SDKClient,\n params?: ChainsRequest,\n options?: RequestOptions\n): Promise<ExtendedChain[]> => {\n return await _getChains(client.config, params, options)\n}\n\nexport const _getChains = async (\n config: SDKBaseConfig,\n params?: ChainsRequest,\n options?: RequestOptions\n): Promise<ExtendedChain[]> => {\n if (params) {\n for (const key of Object.keys(params)) {\n const value = params[key as keyof ChainsRequest]\n if (value === undefined || value === null) {\n delete params[key as keyof ChainsRequest]\n }\n }\n }\n const urlSearchParams = new URLSearchParams(\n params as Record<string, string>\n ).toString()\n const response = await withDedupe(\n () =>\n request<ChainsResponse>(\n config,\n `${config.apiUrl}/chains?${urlSearchParams}`,\n {\n signal: options?.signal,\n }\n ),\n { id: `${getChains.name}.${urlSearchParams}` }\n )\n return response.chains\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,YAAY,OACvB,QACA,QACA,YAC6B;AAC7B,QAAO,MAAM,WAAW,OAAO,QAAQ,QAAQ,QAAQ;;AAGzD,MAAa,aAAa,OACxB,QACA,QACA,YAC6B;AAC7B,KAAI,OACF,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;EACrC,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,KAAA,KAAa,UAAU,KACnC,QAAO,OAAO;;CAIpB,MAAM,kBAAkB,IAAI,gBAC1B,OACD,CAAC,UAAU;AAYZ,SAAO,MAXgBA,yBAAAA,iBAEnBC,sBAAAA,QACE,QACA,GAAG,OAAO,OAAO,UAAU,mBAC3B,EACE,QAAQ,SAAS,QAClB,CACF,EACH,EAAE,IAAI,GAAG,UAAU,KAAK,GAAG,mBAAmB,CAC/C,EACe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConnections.js","names":["request"],"sources":["../../../src/actions/getConnections.ts"],"sourcesContent":["import type {\n ConnectionsRequest,\n ConnectionsResponse,\n RequestOptions,\n} from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get all the available connections for swap/bridging tokens\n * @param client - The SDK client\n * @param connectionRequest ConnectionsRequest\n * @param options - Request options\n * @returns ConnectionsResponse\n */\nexport const getConnections = async (\n client: SDKClient,\n connectionRequest: ConnectionsRequest,\n options?: RequestOptions\n): Promise<ConnectionsResponse> => {\n const url = new URL(`${client.config.apiUrl}/connections`)\n\n const { fromChain, fromToken, toChain, toToken } = connectionRequest\n\n if (fromChain) {\n url.searchParams.append('fromChain', fromChain as unknown as string)\n }\n if (fromToken) {\n url.searchParams.append('fromToken', fromToken)\n }\n if (toChain) {\n url.searchParams.append('toChain', toChain as unknown as string)\n }\n if (toToken) {\n url.searchParams.append('toToken', toToken)\n }\n const connectionRequestArrayParams: Array<keyof ConnectionsRequest> = [\n 'allowBridges',\n 'denyBridges',\n 'preferBridges',\n 'allowExchanges',\n 'denyExchanges',\n 'preferExchanges',\n ]\n for (const parameter of connectionRequestArrayParams) {\n const connectionRequestArrayParam = connectionRequest[parameter] as string[]\n\n if (connectionRequestArrayParam?.length) {\n for (const value of connectionRequestArrayParam) {\n url.searchParams.append(parameter, value)\n }\n }\n }\n return await request<ConnectionsResponse>(client.config, url, options)\n}\n"],"mappings":";;;;;;;;;;AAeA,MAAa,iBAAiB,OAC5B,QACA,mBACA,YACiC;CACjC,MAAM,MAAM,IAAI,IAAI,GAAG,OAAO,OAAO,OAAO,cAAc;CAE1D,MAAM,EAAE,WAAW,WAAW,SAAS,YAAY;AAEnD,KAAI,UACF,KAAI,aAAa,OAAO,aAAa,UAA+B;AAEtE,KAAI,UACF,KAAI,aAAa,OAAO,aAAa,UAAU;AAEjD,KAAI,QACF,KAAI,aAAa,OAAO,WAAW,QAA6B;AAElE,KAAI,QACF,KAAI,aAAa,OAAO,WAAW,QAAQ;AAU7C,MAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"getConnections.js","names":["request"],"sources":["../../../src/actions/getConnections.ts"],"sourcesContent":["import type {\n ConnectionsRequest,\n ConnectionsResponse,\n RequestOptions,\n} from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get all the available connections for swap/bridging tokens\n * @param client - The SDK client\n * @param connectionRequest ConnectionsRequest\n * @param options - Request options\n * @returns ConnectionsResponse\n */\nexport const getConnections = async (\n client: SDKClient,\n connectionRequest: ConnectionsRequest,\n options?: RequestOptions\n): Promise<ConnectionsResponse> => {\n const url = new URL(`${client.config.apiUrl}/connections`)\n\n const { fromChain, fromToken, toChain, toToken } = connectionRequest\n\n if (fromChain) {\n url.searchParams.append('fromChain', fromChain as unknown as string)\n }\n if (fromToken) {\n url.searchParams.append('fromToken', fromToken)\n }\n if (toChain) {\n url.searchParams.append('toChain', toChain as unknown as string)\n }\n if (toToken) {\n url.searchParams.append('toToken', toToken)\n }\n const connectionRequestArrayParams: Array<keyof ConnectionsRequest> = [\n 'allowBridges',\n 'denyBridges',\n 'preferBridges',\n 'allowExchanges',\n 'denyExchanges',\n 'preferExchanges',\n ]\n for (const parameter of connectionRequestArrayParams) {\n const connectionRequestArrayParam = connectionRequest[parameter] as string[]\n\n if (connectionRequestArrayParam?.length) {\n for (const value of connectionRequestArrayParam) {\n url.searchParams.append(parameter, value)\n }\n }\n }\n return await request<ConnectionsResponse>(client.config, url, options)\n}\n"],"mappings":";;;;;;;;;;AAeA,MAAa,iBAAiB,OAC5B,QACA,mBACA,YACiC;CACjC,MAAM,MAAM,IAAI,IAAI,GAAG,OAAO,OAAO,OAAO,cAAc;CAE1D,MAAM,EAAE,WAAW,WAAW,SAAS,YAAY;AAEnD,KAAI,UACF,KAAI,aAAa,OAAO,aAAa,UAA+B;AAEtE,KAAI,UACF,KAAI,aAAa,OAAO,aAAa,UAAU;AAEjD,KAAI,QACF,KAAI,aAAa,OAAO,WAAW,QAA6B;AAElE,KAAI,QACF,KAAI,aAAa,OAAO,WAAW,QAAQ;AAU7C,MAAK,MAAM,aAAa;EAPtB;EACA;EACA;EACA;EACA;EACA;EAEkD,EAAE;EACpD,MAAM,8BAA8B,kBAAkB;AAEtD,MAAI,6BAA6B,OAC/B,MAAK,MAAM,SAAS,4BAClB,KAAI,aAAa,OAAO,WAAW,MAAM;;AAI/C,QAAO,MAAMA,sBAAAA,QAA6B,OAAO,QAAQ,KAAK,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getContractCallsQuote.js","names":["SDKError","ValidationError","request"],"sources":["../../../src/actions/getContractCallsQuote.ts"],"sourcesContent":["import type {\n ContractCallsQuoteRequest,\n LiFiStep,\n RequestOptions,\n} from '@lifi/types'\nimport {\n isContractCallsRequestWithFromAmount,\n isContractCallsRequestWithToAmount,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a destination contract call\n * @param client - The SDK client\n * @param params - The configuration of the requested destination call\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns - Returns step.\n */\nexport const getContractCallsQuote = async (\n client: SDKClient,\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n // validation\n const requiredParameters: Array<keyof ContractCallsQuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n 'contractCalls',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n if (\n !isContractCallsRequestWithFromAmount(params) &&\n !isContractCallsRequestWithToAmount(params)\n ) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"fromAmount\" or \"toAmount\" is missing.`\n )\n )\n }\n // apply defaults\n // option.order is not used in this endpoint\n params.integrator ??= client.config.integrator\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n // send request\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/quote/contractCalls`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAa,wBAAwB,OACnC,QACA,QACA,YACsB;AAUtB,MAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"getContractCallsQuote.js","names":["SDKError","ValidationError","request"],"sources":["../../../src/actions/getContractCallsQuote.ts"],"sourcesContent":["import type {\n ContractCallsQuoteRequest,\n LiFiStep,\n RequestOptions,\n} from '@lifi/types'\nimport {\n isContractCallsRequestWithFromAmount,\n isContractCallsRequestWithToAmount,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a destination contract call\n * @param client - The SDK client\n * @param params - The configuration of the requested destination call\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns - Returns step.\n */\nexport const getContractCallsQuote = async (\n client: SDKClient,\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n // validation\n const requiredParameters: Array<keyof ContractCallsQuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n 'contractCalls',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n if (\n !isContractCallsRequestWithFromAmount(params) &&\n !isContractCallsRequestWithToAmount(params)\n ) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"fromAmount\" or \"toAmount\" is missing.`\n )\n )\n }\n // apply defaults\n // option.order is not used in this endpoint\n params.integrator ??= client.config.integrator\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n // send request\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/quote/contractCalls`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAa,wBAAwB,OACnC,QACA,QACA,YACsB;AAUtB,MAAK,MAAM,qBAAqB;EAP9B;EACA;EACA;EACA;EACA;EACA;EAEgD,CAChD,KAAI,CAAC,OAAO,mBACV,OAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;AAGL,KACE,EAAA,GAAA,YAAA,sCAAsC,OAAO,IAC7C,EAAA,GAAA,YAAA,oCAAoC,OAAO,CAE3C,OAAM,IAAID,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,4DACD,CACF;AAIH,QAAO,eAAe,OAAO,OAAO;AACpC,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,QAAO,MAAMC,sBAAAA,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,uBACxB;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,oBACjB;EACD,MAAM,KAAK,UAAU,OAAO;EAC5B,QAAQ,SAAS;EAClB,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNameServiceAddress.js","names":[],"sources":["../../../src/actions/getNameServiceAddress.ts"],"sourcesContent":["import type { ChainType } from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\n\n/**\n * Get the address of a name service\n * @param client - The SDK client\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 */\nexport const getNameServiceAddress = async (\n client: SDKClient,\n name: string,\n chainType?: ChainType\n): Promise<string | undefined> => {\n try {\n let providers = []\n if (chainType) {\n providers = client.providers.filter(\n (provider) => provider.type === chainType\n )\n } else {\n providers = client.providers\n }\n const resolvers = providers.map((provider) => provider.resolveAddress)\n if (!resolvers.length) {\n return\n }\n const result = await Promise.any(\n resolvers.map(async (resolve) => {\n const address = await resolve(name, client)\n if (!address) {\n throw undefined\n }\n return address\n })\n )\n return result\n } catch (_) {\n return\n }\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,wBAAwB,OACnC,QACA,MACA,cACgC;AAChC,KAAI;EACF,IAAI,YAAY,EAAE;AAClB,MAAI,UACF,aAAY,OAAO,UAAU,QAC1B,aAAa,SAAS,SAAS,UACjC;MAED,aAAY,OAAO;EAErB,MAAM,YAAY,UAAU,KAAK,aAAa,SAAS,eAAe;AACtE,MAAI,CAAC,UAAU,OACb;AAWF,
|
|
1
|
+
{"version":3,"file":"getNameServiceAddress.js","names":[],"sources":["../../../src/actions/getNameServiceAddress.ts"],"sourcesContent":["import type { ChainType } from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\n\n/**\n * Get the address of a name service\n * @param client - The SDK client\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 */\nexport const getNameServiceAddress = async (\n client: SDKClient,\n name: string,\n chainType?: ChainType\n): Promise<string | undefined> => {\n try {\n let providers = []\n if (chainType) {\n providers = client.providers.filter(\n (provider) => provider.type === chainType\n )\n } else {\n providers = client.providers\n }\n const resolvers = providers.map((provider) => provider.resolveAddress)\n if (!resolvers.length) {\n return\n }\n const result = await Promise.any(\n resolvers.map(async (resolve) => {\n const address = await resolve(name, client)\n if (!address) {\n throw undefined\n }\n return address\n })\n )\n return result\n } catch (_) {\n return\n }\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,wBAAwB,OACnC,QACA,MACA,cACgC;AAChC,KAAI;EACF,IAAI,YAAY,EAAE;AAClB,MAAI,UACF,aAAY,OAAO,UAAU,QAC1B,aAAa,SAAS,SAAS,UACjC;MAED,aAAY,OAAO;EAErB,MAAM,YAAY,UAAU,KAAK,aAAa,SAAS,eAAe;AACtE,MAAI,CAAC,UAAU,OACb;AAWF,SAAO,MATc,QAAQ,IAC3B,UAAU,IAAI,OAAO,YAAY;GAC/B,MAAM,UAAU,MAAM,QAAQ,MAAM,OAAO;AAC3C,OAAI,CAAC,QACH,OAAM,KAAA;AAER,UAAO;IACP,CACH;UAEM,GAAG;AACV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuote.js","names":["SDKError","ValidationError","request"],"sources":["../../../src/actions/getQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n QuoteRequest,\n QuoteRequestFromAmount,\n QuoteRequestToAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Quote for a token transfer\n */\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestToAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> {\n const requiredParameters: Array<keyof QuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n ]\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const isFromAmountRequest =\n 'fromAmount' in params && params.fromAmount !== undefined\n const isToAmountRequest =\n 'toAmount' in params && params.toAmount !== undefined\n\n if (!isFromAmountRequest && !isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Required parameter \"fromAmount\" or \"toAmount\" is missing.'\n )\n )\n }\n\n if (isFromAmountRequest && isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Cannot provide both \"fromAmount\" and \"toAmount\" parameters.'\n )\n )\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;AA6BA,eAAsB,SACpB,QACA,QACA,SACmB;AASnB,MAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"getQuote.js","names":["SDKError","ValidationError","request"],"sources":["../../../src/actions/getQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n QuoteRequest,\n QuoteRequestFromAmount,\n QuoteRequestToAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Quote for a token transfer\n */\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestToAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> {\n const requiredParameters: Array<keyof QuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n ]\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const isFromAmountRequest =\n 'fromAmount' in params && params.fromAmount !== undefined\n const isToAmountRequest =\n 'toAmount' in params && params.toAmount !== undefined\n\n if (!isFromAmountRequest && !isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Required parameter \"fromAmount\" or \"toAmount\" is missing.'\n )\n )\n }\n\n if (isFromAmountRequest && isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Cannot provide both \"fromAmount\" and \"toAmount\" parameters.'\n )\n )\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;AA6BA,eAAsB,SACpB,QACA,QACA,SACmB;AASnB,MAAK,MAAM,qBAAqB;EAP9B;EACA;EACA;EACA;EACA;EAGgD,CAChD,KAAI,CAAC,OAAO,mBACV,OAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;CAIL,MAAM,sBACJ,gBAAgB,UAAU,OAAO,eAAe,KAAA;CAClD,MAAM,oBACJ,cAAc,UAAU,OAAO,aAAa,KAAA;AAE9C,KAAI,CAAC,uBAAuB,CAAC,kBAC3B,OAAM,IAAID,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,gEACD,CACF;AAGH,KAAI,uBAAuB,kBACzB,OAAM,IAAID,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,kEACD,CACF;AAIH,QAAO,eAAe,OAAO,OAAO;AACpC,QAAO,UAAU,OAAO,OAAO,cAAc;AAC7C,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,KAEtC,QAAO,OAAO;AAIlB,QAAO,MAAMC,sBAAAA,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,GAAG,sBAAsB,UAAU,iBAAiB,GAAG,IAAI,gBACjF,OACD,IACD,EACE,QAAQ,SAAS,QAClB,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_errors_baseError = require("../errors/baseError.js");
|
|
3
|
-
|
|
3
|
+
require("../errors/constants.js");
|
|
4
4
|
const require_errors_errors = require("../errors/errors.js");
|
|
5
5
|
const require_errors_SDKError = require("../errors/SDKError.js");
|
|
6
6
|
const require_utils_request = require("../utils/request.js");
|
|
@@ -21,7 +21,7 @@ const getRelayedTransactionStatus = async (client, params, options) => {
|
|
|
21
21
|
const queryParams = new URLSearchParams(otherParams);
|
|
22
22
|
if (require_utils_decode.decodeTaskId(taskId).length >= 3) return await require_actions_getStatus.getStatus(client, params, options);
|
|
23
23
|
const result = await require_utils_request.request(client.config, `${client.config.apiUrl}/relayer/status/${taskId}?${queryParams}`, { signal: options?.signal });
|
|
24
|
-
if (result.status === "error") throw new require_errors_baseError.BaseError(
|
|
24
|
+
if (result.status === "error") throw new require_errors_baseError.BaseError("ServerError", result.data.code, result.data.message);
|
|
25
25
|
return result.data;
|
|
26
26
|
};
|
|
27
27
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRelayedTransactionStatus.js","names":["SDKError","ValidationError","decodeTaskId","getStatus","request","BaseError"
|
|
1
|
+
{"version":3,"file":"getRelayedTransactionStatus.js","names":["SDKError","ValidationError","decodeTaskId","getStatus","request","BaseError"],"sources":["../../../src/actions/getRelayedTransactionStatus.ts"],"sourcesContent":["import type {\n RelayStatusRequest,\n RelayStatusResponse,\n RelayStatusResponseData,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { decodeTaskId } from '../utils/decode.js'\nimport { request } from '../utils/request.js'\nimport { getStatus } from './getStatus.js'\n\n/**\n * Get the status of a relayed transaction\n * @param client - The SDK client\n * @param params - Parameters for the relay status request\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Status of the relayed transaction\n */\nexport const getRelayedTransactionStatus = async (\n client: SDKClient,\n params: RelayStatusRequest,\n options?: RequestOptions\n): Promise<RelayStatusResponseData> => {\n if (!params.taskId) {\n throw new SDKError(\n new ValidationError('Required parameter \"taskId\" is missing.')\n )\n }\n\n const { taskId, ...otherParams } = params\n const queryParams = new URLSearchParams(\n otherParams as unknown as Record<string, string>\n )\n\n const decodedTaskId = decodeTaskId(taskId)\n // Temporary solution during the transition between status endpoints\n if (decodedTaskId.length >= 3) {\n return (await getStatus(\n client,\n params,\n options\n )) as unknown as RelayStatusResponseData\n }\n\n const result = await request<RelayStatusResponse>(\n client.config,\n `${client.config.apiUrl}/relayer/status/${taskId}?${queryParams}`,\n {\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAa,8BAA8B,OACzC,QACA,QACA,YACqC;AACrC,KAAI,CAAC,OAAO,OACV,OAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBAAgB,4CAA0C,CAC/D;CAGH,MAAM,EAAE,QAAQ,GAAG,gBAAgB;CACnC,MAAM,cAAc,IAAI,gBACtB,YACD;AAID,KAFsBC,qBAAAA,aAAa,OAElB,CAAC,UAAU,EAC1B,QAAQ,MAAMC,0BAAAA,UACZ,QACA,QACA,QACD;CAGH,MAAM,SAAS,MAAMC,sBAAAA,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,kBAAkB,OAAO,GAAG,eACpD,EACE,QAAQ,SAAS,QAClB,CACF;AAED,KAAI,OAAO,WAAW,QACpB,OAAM,IAAIC,yBAAAA,UAAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,QACb;AAGH,QAAO,OAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_errors_baseError = require("../errors/baseError.js");
|
|
3
|
-
|
|
3
|
+
require("../errors/constants.js");
|
|
4
4
|
const require_errors_errors = require("../errors/errors.js");
|
|
5
5
|
const require_errors_SDKError = require("../errors/SDKError.js");
|
|
6
6
|
const require_utils_request = require("../utils/request.js");
|
|
@@ -35,7 +35,7 @@ const getRelayerQuote = async (client, params, options) => {
|
|
|
35
35
|
params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer;
|
|
36
36
|
for (const key of Object.keys(params)) if (params[key] === void 0 || params[key] === null) delete params[key];
|
|
37
37
|
const result = await require_utils_request.request(client.config, `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(params)}`, { signal: options?.signal });
|
|
38
|
-
if (result.status === "error") throw new require_errors_baseError.BaseError(
|
|
38
|
+
if (result.status === "error") throw new require_errors_baseError.BaseError("ServerError", result.data.code, result.data.message);
|
|
39
39
|
return result.data;
|
|
40
40
|
};
|
|
41
41
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRelayerQuote.js","names":["SDKError","ValidationError","request","BaseError"
|
|
1
|
+
{"version":3,"file":"getRelayerQuote.js","names":["SDKError","ValidationError","request","BaseError"],"sources":["../../../src/actions/getRelayerQuote.ts"],"sourcesContent":["import type {\n LiFiStep,\n RelayerQuoteResponse,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { QuoteRequest, QuoteRequestFromAmount } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a relayer quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Relayer quote for a token transfer\n */\nexport const getRelayerQuote = async (\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n const requiredParameters: Array<keyof QuoteRequestFromAmount> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'fromAmount',\n 'toChain',\n 'toToken',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n const result = await request<RelayerQuoteResponse>(\n client.config,\n `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAa,kBAAkB,OAC7B,QACA,QACA,YACsB;AAStB,MAAK,MAAM,qBAAqB;EAP9B;EACA;EACA;EACA;EACA;EACA;EAEgD,CAChD,KAAI,CAAC,OAAO,mBACV,OAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;AAKL,QAAO,eAAe,OAAO,OAAO;AACpC,QAAO,UAAU,OAAO,OAAO,cAAc;AAC7C,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,aAAa,OAAO,OAAO,cAAc;AAChD,QAAO,QAAQ,OAAO,OAAO,cAAc;AAC3C,QAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;AAC7D,QAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;AAC5D,QAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;AAC9D,QAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;AACjE,QAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;AAChE,QAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;AAElE,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,KAEtC,QAAO,OAAO;CAIlB,MAAM,SAAS,MAAMC,sBAAAA,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,iBAAiB,IAAI,gBAC3C,OACD,IACD,EACE,QAAQ,SAAS,QAClB,CACF;AAED,KAAI,OAAO,WAAW,QACpB,OAAM,IAAIC,yBAAAA,UAAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,QACb;AAGH,QAAO,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTokenBalances.js","names":["getTokenBalancesByChain"],"sources":["../../../src/actions/getTokenBalances.ts"],"sourcesContent":["import type {\n Token,\n TokenAmount,\n TokenAmountExtended,\n TokenExtended,\n} from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\n\n/**\n * Returns the balances for a list tokens a wallet holds across all aggregated chains.\n * @param client - The SDK client.\n * @param walletAddress - A wallet address.\n * @param tokens - A list of Token (or TokenExtended) objects.\n * @returns A list of objects containing the tokens and the amounts on different 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 getTokenBalances(\n client: SDKClient,\n walletAddress: string,\n tokens: Token[]\n): Promise<TokenAmount[]>\nexport async function getTokenBalances(\n client: SDKClient,\n walletAddress: string,\n tokens: TokenExtended[]\n): Promise<TokenAmountExtended[]> {\n // split by chain\n const tokensByChain = tokens.reduce(\n (tokens, token) => {\n if (!tokens[token.chainId]) {\n tokens[token.chainId] = []\n }\n tokens[token.chainId].push(token)\n return tokens\n },\n {} as { [chainId: number]: Token[] | TokenExtended[] }\n )\n\n const tokenAmountsByChain = await getTokenBalancesByChain(\n client,\n walletAddress,\n tokensByChain\n )\n return Object.values(tokenAmountsByChain).flat()\n}\n"],"mappings":";;;AAuBA,eAAsB,iBACpB,QACA,eACA,QACgC;CAahC,MAAM,sBAAsB,MAAMA,wCAAAA,wBAChC,QACA,eAboB,OAAO,QAC1B,QAAQ,UAAU;AACjB,MAAI,CAAC,OAAO,MAAM,SAChB,QAAO,MAAM,WAAW,EAAE;AAE5B,SAAO,MAAM,SAAS,KAAK,MAAM;AACjC,SAAO;IAET,EAAE,
|
|
1
|
+
{"version":3,"file":"getTokenBalances.js","names":["getTokenBalancesByChain"],"sources":["../../../src/actions/getTokenBalances.ts"],"sourcesContent":["import type {\n Token,\n TokenAmount,\n TokenAmountExtended,\n TokenExtended,\n} from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\n\n/**\n * Returns the balances for a list tokens a wallet holds across all aggregated chains.\n * @param client - The SDK client.\n * @param walletAddress - A wallet address.\n * @param tokens - A list of Token (or TokenExtended) objects.\n * @returns A list of objects containing the tokens and the amounts on different 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 getTokenBalances(\n client: SDKClient,\n walletAddress: string,\n tokens: Token[]\n): Promise<TokenAmount[]>\nexport async function getTokenBalances(\n client: SDKClient,\n walletAddress: string,\n tokens: TokenExtended[]\n): Promise<TokenAmountExtended[]> {\n // split by chain\n const tokensByChain = tokens.reduce(\n (tokens, token) => {\n if (!tokens[token.chainId]) {\n tokens[token.chainId] = []\n }\n tokens[token.chainId].push(token)\n return tokens\n },\n {} as { [chainId: number]: Token[] | TokenExtended[] }\n )\n\n const tokenAmountsByChain = await getTokenBalancesByChain(\n client,\n walletAddress,\n tokensByChain\n )\n return Object.values(tokenAmountsByChain).flat()\n}\n"],"mappings":";;;AAuBA,eAAsB,iBACpB,QACA,eACA,QACgC;CAahC,MAAM,sBAAsB,MAAMA,wCAAAA,wBAChC,QACA,eAboB,OAAO,QAC1B,QAAQ,UAAU;AACjB,MAAI,CAAC,OAAO,MAAM,SAChB,QAAO,MAAM,WAAW,EAAE;AAE5B,SAAO,MAAM,SAAS,KAAK,MAAM;AACjC,SAAO;IAET,EAAE,CAMW,CACd;AACD,QAAO,OAAO,OAAO,oBAAoB,CAAC,MAAM"}
|
|
@@ -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;AACvD,KAAI,CAAC,cACH,OAAM,IAAIA,sBAAAA,gBAAgB,yBAAyB;AAKrD,KAFkB,OAAO,OAAO,cAAc,CAAC,
|
|
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;AACvD,KAAI,CAAC,cACH,OAAM,IAAIA,sBAAAA,gBAAgB,yBAAyB;AAKrD,KAFkB,OAAO,OAAO,cAAc,CAAC,MAChB,CAAC,QAAQ,UAAU,CAACC,sBAAAA,QAAQ,MAAM,CAChD,CAAC,OAChB,OAAM,IAAID,sBAAAA,gBAAgB,yBAAyB;CAGrD,MAAM,WAAW,OAAO,UAAU,MAAM,aACtC,SAAS,UAAU,cAAc,CAClC;AACD,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,0BAA0B,cAAc,gBAAgB;CAG1E,MAAM,sBAEF,EAAE;CACN,MAAM,sBAAsB,MAAM,QAAQ,WACxC,OAAO,KAAK,cAAc,CAAC,IAAI,OAAO,eAAe;EACnD,MAAM,UAAU,OAAO,SAAS,YAAY,GAAG;EAC/C,MAAM,QAAQ,MAAM,OAAO,aAAa,QAAQ;AAChD,MAAI,SAAS,SAAS,MAAM,UAM1B,qBAAoB,WAAW,MALJ,SAAS,WAClC,QACA,eACA,cAAc,SACf;MAKD,qBAAoB,WAAW,cAAc;GAE/C,CACH;AACD,KAAI,OAAO,OAAO;OACX,MAAM,UAAU,oBACnB,KAAI,OAAO,WAAW,WACpB,SAAQ,KAAK,iCAAiC,OAAO,OAAO;;AAIlE,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTokens.js","names":["withDedupe","request"],"sources":["../../../src/actions/getTokens.ts"],"sourcesContent":["import type {\n RequestOptions,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n} from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { withDedupe } from '../utils/withDedupe.js'\n\n/**\n * Get all known tokens.\n * @param client - The SDK client\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns The tokens that are available on the requested chains\n */\nexport async function getTokens(\n client: SDKClient,\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n): Promise<TokensResponse>\nexport async function getTokens(\n client: SDKClient,\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n): Promise<TokensExtendedResponse>\nexport async function getTokens(\n client: SDKClient,\n params?: TokensRequest,\n options?: RequestOptions\n): Promise<TokensResponse> {\n if (params) {\n for (const key of Object.keys(params)) {\n const value = params[key as keyof TokensRequest]\n if (value === undefined || value === null) {\n delete params[key as keyof TokensRequest]\n }\n }\n }\n const urlSearchParams = new URLSearchParams(\n params as Record<string, string>\n ).toString()\n const _isExtended = params?.extended === true\n const response = await withDedupe(\n () =>\n request<\n typeof _isExtended extends true\n ? TokensExtendedResponse\n : TokensResponse\n >(client.config, `${client.config.apiUrl}/tokens?${urlSearchParams}`, {\n signal: options?.signal,\n }),\n { id: `${getTokens.name}.${urlSearchParams}` }\n )\n return response\n}\n"],"mappings":";;;;AA2BA,eAAsB,UACpB,QACA,QACA,SACyB;AACzB,KAAI,OACF,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;EACrC,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,KAAA,KAAa,UAAU,KACnC,QAAO,OAAO;;CAIpB,MAAM,kBAAkB,IAAI,gBAC1B,OACD,CAAC,UAAU;AACQ,SAAQ;AAY5B,
|
|
1
|
+
{"version":3,"file":"getTokens.js","names":["withDedupe","request"],"sources":["../../../src/actions/getTokens.ts"],"sourcesContent":["import type {\n RequestOptions,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n} from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { withDedupe } from '../utils/withDedupe.js'\n\n/**\n * Get all known tokens.\n * @param client - The SDK client\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns The tokens that are available on the requested chains\n */\nexport async function getTokens(\n client: SDKClient,\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n): Promise<TokensResponse>\nexport async function getTokens(\n client: SDKClient,\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n): Promise<TokensExtendedResponse>\nexport async function getTokens(\n client: SDKClient,\n params?: TokensRequest,\n options?: RequestOptions\n): Promise<TokensResponse> {\n if (params) {\n for (const key of Object.keys(params)) {\n const value = params[key as keyof TokensRequest]\n if (value === undefined || value === null) {\n delete params[key as keyof TokensRequest]\n }\n }\n }\n const urlSearchParams = new URLSearchParams(\n params as Record<string, string>\n ).toString()\n const _isExtended = params?.extended === true\n const response = await withDedupe(\n () =>\n request<\n typeof _isExtended extends true\n ? TokensExtendedResponse\n : TokensResponse\n >(client.config, `${client.config.apiUrl}/tokens?${urlSearchParams}`, {\n signal: options?.signal,\n }),\n { id: `${getTokens.name}.${urlSearchParams}` }\n )\n return response\n}\n"],"mappings":";;;;AA2BA,eAAsB,UACpB,QACA,QACA,SACyB;AACzB,KAAI,OACF,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;EACrC,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,KAAA,KAAa,UAAU,KACnC,QAAO,OAAO;;CAIpB,MAAM,kBAAkB,IAAI,gBAC1B,OACD,CAAC,UAAU;AACQ,SAAQ;AAY5B,QAAO,MAXgBA,yBAAAA,iBAEnBC,sBAAAA,QAIE,OAAO,QAAQ,GAAG,OAAO,OAAO,OAAO,UAAU,mBAAmB,EACpE,QAAQ,SAAS,QAClB,CAAC,EACJ,EAAE,IAAI,GAAG,UAAU,KAAK,GAAG,mBAAmB,CAC/C"}
|
|
@@ -1 +1 @@
|
|
|
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;AACnD,KAAI,CAAC,cACH,OAAM,IAAIA,sBAAAA,gBAAgB,yBAAyB;AAWrD,
|
|
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;AACnD,KAAI,CAAC,cACH,OAAM,IAAIA,sBAAAA,gBAAgB,yBAAyB;AAWrD,SAAQ,MAReC,sBAAAA,QACrB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,WAAW,cAAc,0BACjD,EACE,QAAQ,SAAS,QAClB,CACF,GAEiB,YAAY,EAAE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_errors_baseError = require("../errors/baseError.js");
|
|
3
|
-
|
|
3
|
+
require("../errors/constants.js");
|
|
4
4
|
const require_errors_errors = require("../errors/errors.js");
|
|
5
5
|
const require_errors_SDKError = require("../errors/SDKError.js");
|
|
6
6
|
const require_utils_request = require("../utils/request.js");
|
|
@@ -25,7 +25,7 @@ const relayTransaction = async (client, params, options) => {
|
|
|
25
25
|
}),
|
|
26
26
|
signal: options?.signal
|
|
27
27
|
});
|
|
28
|
-
if (result.status === "error") throw new require_errors_baseError.BaseError(
|
|
28
|
+
if (result.status === "error") throw new require_errors_baseError.BaseError("ServerError", result.data.code, result.data.message);
|
|
29
29
|
return result.data;
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relayTransaction.js","names":["SDKError","ValidationError","request","BaseError"
|
|
1
|
+
{"version":3,"file":"relayTransaction.js","names":["SDKError","ValidationError","request","BaseError"],"sources":["../../../src/actions/relayTransaction.ts"],"sourcesContent":["import type {\n RelayRequest,\n RelayResponse,\n RelayResponseData,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Relay a transaction through the relayer service\n * @param client - The SDK client\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Task ID and transaction link for the relayed transaction\n */\nexport const relayTransaction = async (\n client: SDKClient,\n params: RelayRequest,\n options?: RequestOptions\n): Promise<RelayResponseData> => {\n const requiredParameters: Array<keyof RelayRequest> = ['typedData']\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n // Determine if the request is for a gasless relayer service or advanced relayer service\n // We will use the same endpoint for both after the gasless relayer service is deprecated\n const relayerPath = params.typedData.some(\n (t) => t.primaryType === 'PermitWitnessTransferFrom'\n )\n ? '/relayer/relay'\n : '/advanced/relay'\n\n const result = await request<RelayResponse>(\n client.config,\n `${client.config.apiUrl}${relayerPath}`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params, (_, value) => {\n if (typeof value === 'bigint') {\n return value.toString()\n }\n return value\n }),\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAa,mBAAmB,OAC9B,QACA,QACA,YAC+B;AAG/B,MAAK,MAAM,qBAAqB,CAFuB,YAEL,CAChD,KAAI,CAAC,OAAO,mBACV,OAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,uBAAuB,kBAAkB,eAC1C,CACF;CAML,MAAM,cAAc,OAAO,UAAU,MAClC,MAAM,EAAE,gBAAgB,4BAC1B,GACG,mBACA;CAEJ,MAAM,SAAS,MAAMC,sBAAAA,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,SAAS,eAC1B;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,oBACjB;EACD,MAAM,KAAK,UAAU,SAAS,GAAG,UAAU;AACzC,OAAI,OAAO,UAAU,SACnB,QAAO,MAAM,UAAU;AAEzB,UAAO;IACP;EACF,QAAQ,SAAS;EAClB,CACF;AAED,KAAI,OAAO,WAAW,QACpB,OAAM,IAAIC,yBAAAA,UAAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,QACb;AAGH,QAAO,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":["name","version","getClientStorage"],"sources":["../../../src/client/createClient.ts"],"sourcesContent":["import type { ChainId, ChainType, ExtendedChain } from '@lifi/types'\nimport type {\n SDKBaseConfig,\n SDKClient,\n SDKConfig,\n SDKProvider,\n} from '../types/core.js'\nimport { checkPackageUpdates } from '../utils/checkPackageUpdates.js'\nimport { name, version } from '../version.js'\nimport { getClientStorage } from './getClientStorage.js'\n\nexport function createClient(options: SDKConfig): SDKClient {\n if (!options.integrator) {\n throw new Error(\n 'Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk'\n )\n }\n\n if (!options.disableVersionCheck && process.env.NODE_ENV === 'development') {\n checkPackageUpdates(name, version)\n }\n\n const { providers, ...configOptions } = options\n\n const _config: SDKBaseConfig = {\n ...configOptions,\n apiUrl: configOptions?.apiUrl ?? 'https://li.quest/v1',\n rpcUrls: configOptions?.rpcUrls ?? {},\n debug: configOptions?.debug ?? false,\n preloadChains: configOptions?.preloadChains ?? true,\n integrator: configOptions?.integrator ?? 'lifi-sdk',\n }\n\n let _providers: SDKProvider[] = providers ?? []\n const _storage = getClientStorage(_config)\n\n const client: SDKClient = {\n get config() {\n return _config\n },\n get providers() {\n return _providers\n },\n getProvider(type: ChainType) {\n return this.providers.find((provider) => provider.type === type)\n },\n setProviders(newProviders: SDKProvider[]) {\n const providerMap = new Map(\n this.providers.map((provider) => [provider.type, provider])\n )\n for (const provider of newProviders) {\n providerMap.set(provider.type, provider)\n }\n _providers = Array.from(providerMap.values())\n },\n setChains(chains: ExtendedChain[]) {\n _storage.setChains(chains)\n },\n async getChains() {\n return await _storage.getChains()\n },\n async getChainById(chainId: ChainId) {\n const chains = await this.getChains()\n const chain = chains?.find((chain) => chain.id === chainId)\n if (!chain) {\n throw new Error(`ChainId ${chainId} not found`)\n }\n return chain\n },\n async getRpcUrls() {\n return await _storage.getRpcUrls()\n },\n async getRpcUrlsByChainId(chainId: ChainId) {\n const rpcUrls = await this.getRpcUrls()\n const chainRpcUrls = rpcUrls[chainId]\n if (!chainRpcUrls?.length) {\n throw new Error(`RPC URL not found for chainId: ${chainId}`)\n }\n return chainRpcUrls\n },\n }\n\n function extend<TClient extends SDKClient>(\n base: TClient\n ): <TExtensions extends Record<string, any>>(\n extendFn: (client: TClient) => TExtensions\n ) => TClient & TExtensions {\n return (extendFn) => {\n const extensions = extendFn(base)\n const extended = { ...base, ...extensions } as TClient & typeof extensions\n\n // Preserve the extend function for further extensions\n return Object.assign(extended, {\n extend: extend(extended),\n })\n }\n }\n\n return Object.assign(client, { extend: extend(client) })\n}\n"],"mappings":";;;;;AAWA,SAAgB,aAAa,SAA+B;AAC1D,KAAI,CAAC,QAAQ,WACX,OAAM,IAAI,MACR,0GACD;AAGH,KAAI,CAAC,QAAQ,uBAAuB,QAAQ,IAAI,aAAa,cAC3D,mCAAA,oBAAoBA,gBAAAA,MAAMC,gBAAAA,QAAQ;CAGpC,MAAM,EAAE,WAAW,GAAG,kBAAkB;CAExC,MAAM,UAAyB;EAC7B,GAAG;EACH,QAAQ,eAAe,UAAU;EACjC,SAAS,eAAe,WAAW,EAAE;EACrC,OAAO,eAAe,SAAS;EAC/B,eAAe,eAAe,iBAAiB;EAC/C,YAAY,eAAe,cAAc;EAC1C;CAED,IAAI,aAA4B,aAAa,EAAE;CAC/C,MAAM,WAAWC,gCAAAA,iBAAiB,QAAQ;CAE1C,MAAM,SAAoB;EACxB,IAAI,SAAS;AACX,UAAO;;EAET,IAAI,YAAY;AACd,UAAO;;EAET,YAAY,MAAiB;AAC3B,UAAO,KAAK,UAAU,MAAM,aAAa,SAAS,SAAS,KAAK;;EAElE,aAAa,cAA6B;GACxC,MAAM,cAAc,IAAI,IACtB,KAAK,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,SAAS,CAAC,CAC5D;AACD,QAAK,MAAM,YAAY,aACrB,aAAY,IAAI,SAAS,MAAM,SAAS;AAE1C,gBAAa,MAAM,KAAK,YAAY,QAAQ,CAAC;;EAE/C,UAAU,QAAyB;AACjC,YAAS,UAAU,OAAO;;EAE5B,MAAM,YAAY;AAChB,UAAO,MAAM,SAAS,WAAW;;EAEnC,MAAM,aAAa,SAAkB;GAEnC,MAAM,
|
|
1
|
+
{"version":3,"file":"createClient.js","names":["name","version","getClientStorage"],"sources":["../../../src/client/createClient.ts"],"sourcesContent":["import type { ChainId, ChainType, ExtendedChain } from '@lifi/types'\nimport type {\n SDKBaseConfig,\n SDKClient,\n SDKConfig,\n SDKProvider,\n} from '../types/core.js'\nimport { checkPackageUpdates } from '../utils/checkPackageUpdates.js'\nimport { name, version } from '../version.js'\nimport { getClientStorage } from './getClientStorage.js'\n\nexport function createClient(options: SDKConfig): SDKClient {\n if (!options.integrator) {\n throw new Error(\n 'Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk'\n )\n }\n\n if (!options.disableVersionCheck && process.env.NODE_ENV === 'development') {\n checkPackageUpdates(name, version)\n }\n\n const { providers, ...configOptions } = options\n\n const _config: SDKBaseConfig = {\n ...configOptions,\n apiUrl: configOptions?.apiUrl ?? 'https://li.quest/v1',\n rpcUrls: configOptions?.rpcUrls ?? {},\n debug: configOptions?.debug ?? false,\n preloadChains: configOptions?.preloadChains ?? true,\n integrator: configOptions?.integrator ?? 'lifi-sdk',\n }\n\n let _providers: SDKProvider[] = providers ?? []\n const _storage = getClientStorage(_config)\n\n const client: SDKClient = {\n get config() {\n return _config\n },\n get providers() {\n return _providers\n },\n getProvider(type: ChainType) {\n return this.providers.find((provider) => provider.type === type)\n },\n setProviders(newProviders: SDKProvider[]) {\n const providerMap = new Map(\n this.providers.map((provider) => [provider.type, provider])\n )\n for (const provider of newProviders) {\n providerMap.set(provider.type, provider)\n }\n _providers = Array.from(providerMap.values())\n },\n setChains(chains: ExtendedChain[]) {\n _storage.setChains(chains)\n },\n async getChains() {\n return await _storage.getChains()\n },\n async getChainById(chainId: ChainId) {\n const chains = await this.getChains()\n const chain = chains?.find((chain) => chain.id === chainId)\n if (!chain) {\n throw new Error(`ChainId ${chainId} not found`)\n }\n return chain\n },\n async getRpcUrls() {\n return await _storage.getRpcUrls()\n },\n async getRpcUrlsByChainId(chainId: ChainId) {\n const rpcUrls = await this.getRpcUrls()\n const chainRpcUrls = rpcUrls[chainId]\n if (!chainRpcUrls?.length) {\n throw new Error(`RPC URL not found for chainId: ${chainId}`)\n }\n return chainRpcUrls\n },\n }\n\n function extend<TClient extends SDKClient>(\n base: TClient\n ): <TExtensions extends Record<string, any>>(\n extendFn: (client: TClient) => TExtensions\n ) => TClient & TExtensions {\n return (extendFn) => {\n const extensions = extendFn(base)\n const extended = { ...base, ...extensions } as TClient & typeof extensions\n\n // Preserve the extend function for further extensions\n return Object.assign(extended, {\n extend: extend(extended),\n })\n }\n }\n\n return Object.assign(client, { extend: extend(client) })\n}\n"],"mappings":";;;;;AAWA,SAAgB,aAAa,SAA+B;AAC1D,KAAI,CAAC,QAAQ,WACX,OAAM,IAAI,MACR,0GACD;AAGH,KAAI,CAAC,QAAQ,uBAAuB,QAAQ,IAAI,aAAa,cAC3D,mCAAA,oBAAoBA,gBAAAA,MAAMC,gBAAAA,QAAQ;CAGpC,MAAM,EAAE,WAAW,GAAG,kBAAkB;CAExC,MAAM,UAAyB;EAC7B,GAAG;EACH,QAAQ,eAAe,UAAU;EACjC,SAAS,eAAe,WAAW,EAAE;EACrC,OAAO,eAAe,SAAS;EAC/B,eAAe,eAAe,iBAAiB;EAC/C,YAAY,eAAe,cAAc;EAC1C;CAED,IAAI,aAA4B,aAAa,EAAE;CAC/C,MAAM,WAAWC,gCAAAA,iBAAiB,QAAQ;CAE1C,MAAM,SAAoB;EACxB,IAAI,SAAS;AACX,UAAO;;EAET,IAAI,YAAY;AACd,UAAO;;EAET,YAAY,MAAiB;AAC3B,UAAO,KAAK,UAAU,MAAM,aAAa,SAAS,SAAS,KAAK;;EAElE,aAAa,cAA6B;GACxC,MAAM,cAAc,IAAI,IACtB,KAAK,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,SAAS,CAAC,CAC5D;AACD,QAAK,MAAM,YAAY,aACrB,aAAY,IAAI,SAAS,MAAM,SAAS;AAE1C,gBAAa,MAAM,KAAK,YAAY,QAAQ,CAAC;;EAE/C,UAAU,QAAyB;AACjC,YAAS,UAAU,OAAO;;EAE5B,MAAM,YAAY;AAChB,UAAO,MAAM,SAAS,WAAW;;EAEnC,MAAM,aAAa,SAAkB;GAEnC,MAAM,SAAQ,MADO,KAAK,WAAW,GACf,MAAM,UAAU,MAAM,OAAO,QAAQ;AAC3D,OAAI,CAAC,MACH,OAAM,IAAI,MAAM,WAAW,QAAQ,YAAY;AAEjD,UAAO;;EAET,MAAM,aAAa;AACjB,UAAO,MAAM,SAAS,YAAY;;EAEpC,MAAM,oBAAoB,SAAkB;GAE1C,MAAM,gBAAe,MADC,KAAK,YAAY,EACV;AAC7B,OAAI,CAAC,cAAc,OACjB,OAAM,IAAI,MAAM,kCAAkC,UAAU;AAE9D,UAAO;;EAEV;CAED,SAAS,OACP,MAGyB;AACzB,UAAQ,aAAa;GACnB,MAAM,aAAa,SAAS,KAAK;GACjC,MAAM,WAAW;IAAE,GAAG;IAAM,GAAG;IAAY;AAG3C,UAAO,OAAO,OAAO,UAAU,EAC7B,QAAQ,OAAO,SAAS,EACzB,CAAC;;;AAIN,QAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseStepExecutor.js","names":["StatusManager","ExecuteStepRetryError"],"sources":["../../../src/core/BaseStepExecutor.ts"],"sourcesContent":["import { ExecuteStepRetryError } from '../errors/errors.js'\nimport type { SDKError } from '../errors/SDKError.js'\nimport type {\n ExecuteStepRetryParams,\n ExecutionAction,\n ExecutionOptions,\n InteractionSettings,\n LiFiStepExtended,\n SDKClient,\n StepExecutor,\n StepExecutorOptions,\n} from '../types/core.js'\nimport type {\n StepExecutorBaseContext,\n StepExecutorContext,\n} from '../types/execution.js'\nimport { StatusManager } from './StatusManager.js'\nimport type { TaskPipeline } from './TaskPipeline.js'\n\n// Please be careful when changing the defaults as it may break the behavior (e.g., background execution)\nconst defaultInteractionSettings = {\n allowInteraction: true,\n allowUpdates: true,\n allowExecution: true,\n}\n\nexport abstract class BaseStepExecutor implements StepExecutor {\n protected executionOptions?: ExecutionOptions\n protected statusManager: StatusManager\n\n public allowUserInteraction = true\n public allowExecution = true\n\n constructor(options: StepExecutorOptions) {\n this.statusManager = new StatusManager(options.routeId)\n this.executionOptions = options.executionOptions\n }\n\n setInteraction = (settings?: InteractionSettings): void => {\n const interactionSettings = {\n ...defaultInteractionSettings,\n ...settings,\n }\n this.allowUserInteraction = interactionSettings.allowInteraction\n this.statusManager.allowUpdates(interactionSettings.allowUpdates)\n this.allowExecution = interactionSettings.allowExecution\n }\n\n private createBaseContext = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams\n ): Promise<StepExecutorBaseContext> => {\n const fromChain = await client.getChainById(step.action.fromChainId)\n const toChain = await client.getChainById(step.action.toChainId)\n\n const isBridgeExecution = fromChain.id !== toChain.id\n\n return {\n client,\n step,\n fromChain,\n toChain,\n isBridgeExecution,\n retryParams,\n statusManager: this.statusManager,\n executionOptions: this.executionOptions,\n allowUserInteraction: this.allowUserInteraction,\n }\n }\n\n abstract createContext(\n baseContext: StepExecutorBaseContext\n ): Promise<StepExecutorContext>\n\n abstract createPipeline(context: StepExecutorContext): TaskPipeline\n\n abstract parseErrors(\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError>\n\n executeStep = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams\n ): Promise<LiFiStepExtended> => {\n try {\n step.execution = this.statusManager.initializeExecution(step)\n\n const baseContext = await this.createBaseContext(\n client,\n step,\n retryParams\n )\n const context = await this.createContext(baseContext)\n const pipeline = this.createPipeline(context)\n\n await pipeline.run(context)\n\n return step\n } catch (error: any) {\n // Derive failing action from last in execution.actions\n const action = step.execution?.actions?.at(-1)\n const parsed = await this.parseErrors(error, step, action, retryParams)\n if (!(parsed instanceof ExecuteStepRetryError)) {\n if (action) {\n this.statusManager.updateAction(step, action.type, 'FAILED', {\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n } else {\n this.statusManager.updateExecution(step, {\n status: 'FAILED',\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n }\n }\n throw parsed\n }\n }\n}\n"],"mappings":";;;;AAoBA,MAAM,6BAA6B;CACjC,kBAAkB;CAClB,cAAc;CACd,gBAAgB;CACjB;AAED,IAAsB,mBAAtB,MAA+D;CAC7D;CACA;CAEA,uBAA8B;CAC9B,iBAAwB;CAExB,YAAY,SAA8B;AACxC,OAAK,gBAAgB,IAAIA,2BAAAA,cAAc,QAAQ,QAAQ;AACvD,OAAK,mBAAmB,QAAQ;;CAGlC,kBAAkB,aAAyC;EACzD,MAAM,sBAAsB;GAC1B,GAAG;GACH,GAAG;GACJ;AACD,OAAK,uBAAuB,oBAAoB;AAChD,OAAK,cAAc,aAAa,oBAAoB,aAAa;AACjE,OAAK,iBAAiB,oBAAoB;;CAG5C,oBAA4B,OAC1B,QACA,MACA,gBACqC;EACrC,MAAM,YAAY,MAAM,OAAO,aAAa,KAAK,OAAO,YAAY;EACpE,MAAM,UAAU,MAAM,OAAO,aAAa,KAAK,OAAO,UAAU;AAIhE,SAAO;GACL;GACA;GACA;GACA;GACA,mBAPwB,UAAU,OAAO,QAAQ;GAQjD;GACA,eAAe,KAAK;GACpB,kBAAkB,KAAK;GACvB,sBAAsB,KAAK;GAC5B;;CAgBH,cAAc,OACZ,QACA,MACA,gBAC8B;AAC9B,MAAI;AACF,QAAK,YAAY,KAAK,cAAc,oBAAoB,KAAK;GAE7D,MAAM,cAAc,MAAM,KAAK,kBAC7B,QACA,MACA,YACD;GACD,MAAM,UAAU,MAAM,KAAK,cAAc,YAAY;AAGrD,SAFiB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"BaseStepExecutor.js","names":["StatusManager","ExecuteStepRetryError"],"sources":["../../../src/core/BaseStepExecutor.ts"],"sourcesContent":["import { ExecuteStepRetryError } from '../errors/errors.js'\nimport type { SDKError } from '../errors/SDKError.js'\nimport type {\n ExecuteStepRetryParams,\n ExecutionAction,\n ExecutionOptions,\n InteractionSettings,\n LiFiStepExtended,\n SDKClient,\n StepExecutor,\n StepExecutorOptions,\n} from '../types/core.js'\nimport type {\n StepExecutorBaseContext,\n StepExecutorContext,\n} from '../types/execution.js'\nimport { StatusManager } from './StatusManager.js'\nimport type { TaskPipeline } from './TaskPipeline.js'\n\n// Please be careful when changing the defaults as it may break the behavior (e.g., background execution)\nconst defaultInteractionSettings = {\n allowInteraction: true,\n allowUpdates: true,\n allowExecution: true,\n}\n\nexport abstract class BaseStepExecutor implements StepExecutor {\n protected executionOptions?: ExecutionOptions\n protected statusManager: StatusManager\n\n public allowUserInteraction = true\n public allowExecution = true\n\n constructor(options: StepExecutorOptions) {\n this.statusManager = new StatusManager(options.routeId)\n this.executionOptions = options.executionOptions\n }\n\n setInteraction = (settings?: InteractionSettings): void => {\n const interactionSettings = {\n ...defaultInteractionSettings,\n ...settings,\n }\n this.allowUserInteraction = interactionSettings.allowInteraction\n this.statusManager.allowUpdates(interactionSettings.allowUpdates)\n this.allowExecution = interactionSettings.allowExecution\n }\n\n private createBaseContext = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams\n ): Promise<StepExecutorBaseContext> => {\n const fromChain = await client.getChainById(step.action.fromChainId)\n const toChain = await client.getChainById(step.action.toChainId)\n\n const isBridgeExecution = fromChain.id !== toChain.id\n\n return {\n client,\n step,\n fromChain,\n toChain,\n isBridgeExecution,\n retryParams,\n statusManager: this.statusManager,\n executionOptions: this.executionOptions,\n allowUserInteraction: this.allowUserInteraction,\n }\n }\n\n abstract createContext(\n baseContext: StepExecutorBaseContext\n ): Promise<StepExecutorContext>\n\n abstract createPipeline(context: StepExecutorContext): TaskPipeline\n\n abstract parseErrors(\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError>\n\n executeStep = async (\n client: SDKClient,\n step: LiFiStepExtended,\n retryParams?: ExecuteStepRetryParams\n ): Promise<LiFiStepExtended> => {\n try {\n step.execution = this.statusManager.initializeExecution(step)\n\n const baseContext = await this.createBaseContext(\n client,\n step,\n retryParams\n )\n const context = await this.createContext(baseContext)\n const pipeline = this.createPipeline(context)\n\n await pipeline.run(context)\n\n return step\n } catch (error: any) {\n // Derive failing action from last in execution.actions\n const action = step.execution?.actions?.at(-1)\n const parsed = await this.parseErrors(error, step, action, retryParams)\n if (!(parsed instanceof ExecuteStepRetryError)) {\n if (action) {\n this.statusManager.updateAction(step, action.type, 'FAILED', {\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n } else {\n this.statusManager.updateExecution(step, {\n status: 'FAILED',\n error: {\n message: parsed.cause?.message,\n code: parsed.code,\n },\n })\n }\n }\n throw parsed\n }\n }\n}\n"],"mappings":";;;;AAoBA,MAAM,6BAA6B;CACjC,kBAAkB;CAClB,cAAc;CACd,gBAAgB;CACjB;AAED,IAAsB,mBAAtB,MAA+D;CAC7D;CACA;CAEA,uBAA8B;CAC9B,iBAAwB;CAExB,YAAY,SAA8B;AACxC,OAAK,gBAAgB,IAAIA,2BAAAA,cAAc,QAAQ,QAAQ;AACvD,OAAK,mBAAmB,QAAQ;;CAGlC,kBAAkB,aAAyC;EACzD,MAAM,sBAAsB;GAC1B,GAAG;GACH,GAAG;GACJ;AACD,OAAK,uBAAuB,oBAAoB;AAChD,OAAK,cAAc,aAAa,oBAAoB,aAAa;AACjE,OAAK,iBAAiB,oBAAoB;;CAG5C,oBAA4B,OAC1B,QACA,MACA,gBACqC;EACrC,MAAM,YAAY,MAAM,OAAO,aAAa,KAAK,OAAO,YAAY;EACpE,MAAM,UAAU,MAAM,OAAO,aAAa,KAAK,OAAO,UAAU;AAIhE,SAAO;GACL;GACA;GACA;GACA;GACA,mBAPwB,UAAU,OAAO,QAAQ;GAQjD;GACA,eAAe,KAAK;GACpB,kBAAkB,KAAK;GACvB,sBAAsB,KAAK;GAC5B;;CAgBH,cAAc,OACZ,QACA,MACA,gBAC8B;AAC9B,MAAI;AACF,QAAK,YAAY,KAAK,cAAc,oBAAoB,KAAK;GAE7D,MAAM,cAAc,MAAM,KAAK,kBAC7B,QACA,MACA,YACD;GACD,MAAM,UAAU,MAAM,KAAK,cAAc,YAAY;AAGrD,SAFiB,KAAK,eAAe,QAEvB,CAAC,IAAI,QAAQ;AAE3B,UAAO;WACA,OAAY;GAEnB,MAAM,SAAS,KAAK,WAAW,SAAS,GAAG,GAAG;GAC9C,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,QAAQ,YAAY;AACvE,OAAI,EAAE,kBAAkBC,sBAAAA,uBACtB,KAAI,OACF,MAAK,cAAc,aAAa,MAAM,OAAO,MAAM,UAAU,EAC3D,OAAO;IACL,SAAS,OAAO,OAAO;IACvB,MAAM,OAAO;IACd,EACF,CAAC;OAEF,MAAK,cAAc,gBAAgB,MAAM;IACvC,QAAQ;IACR,OAAO;KACL,SAAS,OAAO,OAAO;KACvB,MAAM,OAAO;KACd;IACF,CAAC;AAGN,SAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusManager.js","names":["getActionMessage","executionState"],"sources":["../../../src/core/StatusManager.ts"],"sourcesContent":["import type { ChainId, LiFiStep } from '@lifi/types'\nimport type {\n Execution,\n ExecutionAction,\n ExecutionActionStatus,\n ExecutionActionType,\n LiFiStepExtended,\n} from '../types/core.js'\nimport { getActionMessage } from './actionMessages.js'\nimport { executionState } from './executionState.js'\n\ntype ActionProps = {\n step: LiFiStepExtended\n type: ExecutionActionType\n chainId: ChainId\n status: ExecutionActionStatus\n}\n\n/**\n * Manages status updates of a route and provides various functions for tracking actions.\n */\nexport class StatusManager {\n private readonly routeId: string\n private shouldUpdate = true\n\n constructor(routeId: string) {\n this.routeId = routeId\n }\n\n /**\n * Initializes the execution object of a Step.\n * @param step The current step in execution\n * @returns The initialized execution object for this step\n */\n initializeExecution = (step: LiFiStepExtended): Execution => {\n if (!step.execution) {\n step.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [],\n }\n this.updateStepInRoute(step)\n }\n\n // Change status to PENDING after resuming from FAILED\n if (step.execution.status === 'FAILED') {\n step.execution.startedAt = Date.now()\n step.execution.status = 'PENDING'\n step.execution.signedAt = undefined\n step.execution.error = undefined\n this.updateStepInRoute(step)\n }\n\n return step.execution\n }\n\n /**\n * Updates the execution object of a Step.\n * @param step The current step in execution\n * @param execution Partial execution data to merge\n * @returns The step with the updated execution object\n */\n updateExecution(\n step: LiFiStepExtended,\n execution: Partial<Execution>\n ): LiFiStep {\n if (!step.execution) {\n throw Error(\"Can't update empty execution.\")\n }\n step.execution = {\n ...step.execution,\n ...execution,\n }\n this.updateStepInRoute(step)\n return step\n }\n\n /**\n * Finds an action of the specified type in the step's execution\n * @param step The step to search in\n * @param type The action type to find\n * @returns The found action or undefined if not found\n */\n findAction(\n step: LiFiStepExtended,\n type: ExecutionActionType\n ): ExecutionAction | undefined {\n if (!step.execution?.actions) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const action = step.execution.actions.find((p) => p.type === type)\n\n return action\n }\n\n /**\n * Create and push a new action into the execution.\n * Caller is responsible for ensuring an action of this type does not already exist.\n * @param step The step that should contain the new action.\n * @param type Type of the action.\n * @param chainId Chain Id of the action.\n * @param status The initial status for the new action.\n * @returns The created action.\n */\n createAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const newAction: ExecutionAction = {\n type,\n message: getActionMessage(type, status),\n status,\n chainId,\n }\n\n step.execution.actions.push(newAction)\n this.updateStepInRoute(step)\n return newAction\n }\n\n /**\n * Find an existing action by type and update it, or create a new one if none exists.\n * @param step The step that should contain the action.\n * @param type Type of the action. Used to identify already existing actions.\n * @param chainId Chain Id of the action (used when creating).\n * @param status The status to set on the found or newly created action.\n * @returns The updated or newly created action.\n */\n initializeAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n const action = this.findAction(step, type)\n\n if (action) {\n return this.updateAction(step, type, status, {\n error: undefined,\n })\n }\n\n return this.createAction({ step, type, chainId, status })\n }\n\n /**\n * Update an action object.\n * @param step The step where the action should be updated\n * @param type The action type to update\n * @param status The status the action gets.\n * @param [params] Additional parameters to append to the action.\n * @returns The updated action\n */\n updateAction = (\n step: LiFiStepExtended,\n type: ExecutionActionType,\n status: ExecutionActionStatus,\n params?: Partial<ExecutionAction & { signedAt?: number }>\n ): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Can't update an empty step execution.\")\n }\n const currentAction = this.findAction(step, type)\n\n if (!currentAction) {\n throw new Error(\"Can't find an action for the given type.\")\n }\n\n switch (status) {\n case 'CANCELLED':\n break\n case 'FAILED':\n step.execution.status = 'FAILED'\n if (params?.error) {\n step.execution.error = params.error\n }\n break\n case 'DONE':\n break\n case 'PENDING':\n step.execution.status = 'PENDING'\n if (params?.signedAt) {\n step.execution.signedAt = params.signedAt\n }\n break\n case 'RESET_REQUIRED':\n case 'MESSAGE_REQUIRED':\n case 'ACTION_REQUIRED':\n step.execution.status = 'ACTION_REQUIRED'\n break\n default:\n break\n }\n\n currentAction.status = status\n currentAction.message = getActionMessage(type, status)\n // set extra parameters or overwrite the standard params set in the switch statement\n if (params) {\n const { signedAt: _signedAt, ...rest } = params\n Object.assign(currentAction, rest)\n }\n // Sort actions, the ones with DONE status go first\n step.execution.actions = [\n ...step.execution.actions.filter((action) => action.status === 'DONE'),\n ...step.execution.actions.filter((action) => action.status !== 'DONE'),\n ]\n this.updateStepInRoute(step) // updates the step in the route\n return currentAction\n }\n\n updateStepInRoute = (step: LiFiStep): LiFiStep => {\n if (!this.shouldUpdate) {\n return step\n }\n const data = executionState.get(this.routeId)\n\n if (!data) {\n throw new Error('Execution data not found.')\n }\n\n const stepIndex = data.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n\n if (stepIndex === -1) {\n throw new Error(\"Couldn't find a step to update.\")\n }\n\n data.route.steps[stepIndex] = { ...data.route.steps[stepIndex], ...step }\n\n data.executionOptions?.updateRouteHook?.(data.route)\n return data.route.steps[stepIndex]\n }\n\n allowUpdates(value: boolean): void {\n this.shouldUpdate = value\n }\n}\n"],"mappings":";;;;;;;AAqBA,IAAa,gBAAb,MAA2B;CACzB;CACA,eAAuB;CAEvB,YAAY,SAAiB;AAC3B,OAAK,UAAU;;;;;;;CAQjB,uBAAuB,SAAsC;AAC3D,MAAI,CAAC,KAAK,WAAW;AACnB,QAAK,YAAY;IACf,WAAW,KAAK,KAAK;IACrB,QAAQ;IACR,SAAS,EAAE;IACZ;AACD,QAAK,kBAAkB,KAAK;;AAI9B,MAAI,KAAK,UAAU,WAAW,UAAU;AACtC,QAAK,UAAU,YAAY,KAAK,KAAK;AACrC,QAAK,UAAU,SAAS;AACxB,QAAK,UAAU,WAAW,KAAA;AAC1B,QAAK,UAAU,QAAQ,KAAA;AACvB,QAAK,kBAAkB,KAAK;;AAG9B,SAAO,KAAK;;;;;;;;CASd,gBACE,MACA,WACU;AACV,MAAI,CAAC,KAAK,UACR,OAAM,MAAM,gCAAgC;AAE9C,OAAK,YAAY;GACf,GAAG,KAAK;GACR,GAAG;GACJ;AACD,OAAK,kBAAkB,KAAK;AAC5B,SAAO;;;;;;;;CAST,WACE,MACA,MAC6B;AAC7B,MAAI,CAAC,KAAK,WAAW,QACnB,OAAM,IAAI,MAAM,qCAAqC;AAKvD,SAFe,KAAK,UAAU,QAAQ,MAAM,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"StatusManager.js","names":["getActionMessage","executionState"],"sources":["../../../src/core/StatusManager.ts"],"sourcesContent":["import type { ChainId, LiFiStep } from '@lifi/types'\nimport type {\n Execution,\n ExecutionAction,\n ExecutionActionStatus,\n ExecutionActionType,\n LiFiStepExtended,\n} from '../types/core.js'\nimport { getActionMessage } from './actionMessages.js'\nimport { executionState } from './executionState.js'\n\ntype ActionProps = {\n step: LiFiStepExtended\n type: ExecutionActionType\n chainId: ChainId\n status: ExecutionActionStatus\n}\n\n/**\n * Manages status updates of a route and provides various functions for tracking actions.\n */\nexport class StatusManager {\n private readonly routeId: string\n private shouldUpdate = true\n\n constructor(routeId: string) {\n this.routeId = routeId\n }\n\n /**\n * Initializes the execution object of a Step.\n * @param step The current step in execution\n * @returns The initialized execution object for this step\n */\n initializeExecution = (step: LiFiStepExtended): Execution => {\n if (!step.execution) {\n step.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [],\n }\n this.updateStepInRoute(step)\n }\n\n // Change status to PENDING after resuming from FAILED\n if (step.execution.status === 'FAILED') {\n step.execution.startedAt = Date.now()\n step.execution.status = 'PENDING'\n step.execution.signedAt = undefined\n step.execution.error = undefined\n this.updateStepInRoute(step)\n }\n\n return step.execution\n }\n\n /**\n * Updates the execution object of a Step.\n * @param step The current step in execution\n * @param execution Partial execution data to merge\n * @returns The step with the updated execution object\n */\n updateExecution(\n step: LiFiStepExtended,\n execution: Partial<Execution>\n ): LiFiStep {\n if (!step.execution) {\n throw Error(\"Can't update empty execution.\")\n }\n step.execution = {\n ...step.execution,\n ...execution,\n }\n this.updateStepInRoute(step)\n return step\n }\n\n /**\n * Finds an action of the specified type in the step's execution\n * @param step The step to search in\n * @param type The action type to find\n * @returns The found action or undefined if not found\n */\n findAction(\n step: LiFiStepExtended,\n type: ExecutionActionType\n ): ExecutionAction | undefined {\n if (!step.execution?.actions) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const action = step.execution.actions.find((p) => p.type === type)\n\n return action\n }\n\n /**\n * Create and push a new action into the execution.\n * Caller is responsible for ensuring an action of this type does not already exist.\n * @param step The step that should contain the new action.\n * @param type Type of the action.\n * @param chainId Chain Id of the action.\n * @param status The initial status for the new action.\n * @returns The created action.\n */\n createAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const newAction: ExecutionAction = {\n type,\n message: getActionMessage(type, status),\n status,\n chainId,\n }\n\n step.execution.actions.push(newAction)\n this.updateStepInRoute(step)\n return newAction\n }\n\n /**\n * Find an existing action by type and update it, or create a new one if none exists.\n * @param step The step that should contain the action.\n * @param type Type of the action. Used to identify already existing actions.\n * @param chainId Chain Id of the action (used when creating).\n * @param status The status to set on the found or newly created action.\n * @returns The updated or newly created action.\n */\n initializeAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n const action = this.findAction(step, type)\n\n if (action) {\n return this.updateAction(step, type, status, {\n error: undefined,\n })\n }\n\n return this.createAction({ step, type, chainId, status })\n }\n\n /**\n * Update an action object.\n * @param step The step where the action should be updated\n * @param type The action type to update\n * @param status The status the action gets.\n * @param [params] Additional parameters to append to the action.\n * @returns The updated action\n */\n updateAction = (\n step: LiFiStepExtended,\n type: ExecutionActionType,\n status: ExecutionActionStatus,\n params?: Partial<ExecutionAction & { signedAt?: number }>\n ): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Can't update an empty step execution.\")\n }\n const currentAction = this.findAction(step, type)\n\n if (!currentAction) {\n throw new Error(\"Can't find an action for the given type.\")\n }\n\n switch (status) {\n case 'CANCELLED':\n break\n case 'FAILED':\n step.execution.status = 'FAILED'\n if (params?.error) {\n step.execution.error = params.error\n }\n break\n case 'DONE':\n break\n case 'PENDING':\n step.execution.status = 'PENDING'\n if (params?.signedAt) {\n step.execution.signedAt = params.signedAt\n }\n break\n case 'RESET_REQUIRED':\n case 'MESSAGE_REQUIRED':\n case 'ACTION_REQUIRED':\n step.execution.status = 'ACTION_REQUIRED'\n break\n default:\n break\n }\n\n currentAction.status = status\n currentAction.message = getActionMessage(type, status)\n // set extra parameters or overwrite the standard params set in the switch statement\n if (params) {\n const { signedAt: _signedAt, ...rest } = params\n Object.assign(currentAction, rest)\n }\n // Sort actions, the ones with DONE status go first\n step.execution.actions = [\n ...step.execution.actions.filter((action) => action.status === 'DONE'),\n ...step.execution.actions.filter((action) => action.status !== 'DONE'),\n ]\n this.updateStepInRoute(step) // updates the step in the route\n return currentAction\n }\n\n updateStepInRoute = (step: LiFiStep): LiFiStep => {\n if (!this.shouldUpdate) {\n return step\n }\n const data = executionState.get(this.routeId)\n\n if (!data) {\n throw new Error('Execution data not found.')\n }\n\n const stepIndex = data.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n\n if (stepIndex === -1) {\n throw new Error(\"Couldn't find a step to update.\")\n }\n\n data.route.steps[stepIndex] = { ...data.route.steps[stepIndex], ...step }\n\n data.executionOptions?.updateRouteHook?.(data.route)\n return data.route.steps[stepIndex]\n }\n\n allowUpdates(value: boolean): void {\n this.shouldUpdate = value\n }\n}\n"],"mappings":";;;;;;;AAqBA,IAAa,gBAAb,MAA2B;CACzB;CACA,eAAuB;CAEvB,YAAY,SAAiB;AAC3B,OAAK,UAAU;;;;;;;CAQjB,uBAAuB,SAAsC;AAC3D,MAAI,CAAC,KAAK,WAAW;AACnB,QAAK,YAAY;IACf,WAAW,KAAK,KAAK;IACrB,QAAQ;IACR,SAAS,EAAE;IACZ;AACD,QAAK,kBAAkB,KAAK;;AAI9B,MAAI,KAAK,UAAU,WAAW,UAAU;AACtC,QAAK,UAAU,YAAY,KAAK,KAAK;AACrC,QAAK,UAAU,SAAS;AACxB,QAAK,UAAU,WAAW,KAAA;AAC1B,QAAK,UAAU,QAAQ,KAAA;AACvB,QAAK,kBAAkB,KAAK;;AAG9B,SAAO,KAAK;;;;;;;;CASd,gBACE,MACA,WACU;AACV,MAAI,CAAC,KAAK,UACR,OAAM,MAAM,gCAAgC;AAE9C,OAAK,YAAY;GACf,GAAG,KAAK;GACR,GAAG;GACJ;AACD,OAAK,kBAAkB,KAAK;AAC5B,SAAO;;;;;;;;CAST,WACE,MACA,MAC6B;AAC7B,MAAI,CAAC,KAAK,WAAW,QACnB,OAAM,IAAI,MAAM,qCAAqC;AAKvD,SAFe,KAAK,UAAU,QAAQ,MAAM,MAAM,EAAE,SAAS,KAEhD;;;;;;;;;;;CAYf,gBAAgB,EACd,MACA,MACA,SACA,aACkC;AAClC,MAAI,CAAC,KAAK,UACR,OAAM,IAAI,MAAM,qCAAqC;EAGvD,MAAM,YAA6B;GACjC;GACA,SAASA,4BAAAA,iBAAiB,MAAM,OAAO;GACvC;GACA;GACD;AAED,OAAK,UAAU,QAAQ,KAAK,UAAU;AACtC,OAAK,kBAAkB,KAAK;AAC5B,SAAO;;;;;;;;;;CAWT,oBAAoB,EAClB,MACA,MACA,SACA,aACkC;AAGlC,MAFe,KAAK,WAAW,MAAM,KAE3B,CACR,QAAO,KAAK,aAAa,MAAM,MAAM,QAAQ,EAC3C,OAAO,KAAA,GACR,CAAC;AAGJ,SAAO,KAAK,aAAa;GAAE;GAAM;GAAM;GAAS;GAAQ,CAAC;;;;;;;;;;CAW3D,gBACE,MACA,MACA,QACA,WACoB;AACpB,MAAI,CAAC,KAAK,UACR,OAAM,IAAI,MAAM,wCAAwC;EAE1D,MAAM,gBAAgB,KAAK,WAAW,MAAM,KAAK;AAEjD,MAAI,CAAC,cACH,OAAM,IAAI,MAAM,2CAA2C;AAG7D,UAAQ,QAAR;GACE,KAAK,YACH;GACF,KAAK;AACH,SAAK,UAAU,SAAS;AACxB,QAAI,QAAQ,MACV,MAAK,UAAU,QAAQ,OAAO;AAEhC;GACF,KAAK,OACH;GACF,KAAK;AACH,SAAK,UAAU,SAAS;AACxB,QAAI,QAAQ,SACV,MAAK,UAAU,WAAW,OAAO;AAEnC;GACF,KAAK;GACL,KAAK;GACL,KAAK;AACH,SAAK,UAAU,SAAS;AACxB;GACF,QACE;;AAGJ,gBAAc,SAAS;AACvB,gBAAc,UAAUA,4BAAAA,iBAAiB,MAAM,OAAO;AAEtD,MAAI,QAAQ;GACV,MAAM,EAAE,UAAU,WAAW,GAAG,SAAS;AACzC,UAAO,OAAO,eAAe,KAAK;;AAGpC,OAAK,UAAU,UAAU,CACvB,GAAG,KAAK,UAAU,QAAQ,QAAQ,WAAW,OAAO,WAAW,OAAO,EACtE,GAAG,KAAK,UAAU,QAAQ,QAAQ,WAAW,OAAO,WAAW,OAAO,CACvE;AACD,OAAK,kBAAkB,KAAK;AAC5B,SAAO;;CAGT,qBAAqB,SAA6B;AAChD,MAAI,CAAC,KAAK,aACR,QAAO;EAET,MAAM,OAAOC,4BAAAA,eAAe,IAAI,KAAK,QAAQ;AAE7C,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,4BAA4B;EAG9C,MAAM,YAAY,KAAK,MAAM,MAAM,WAChC,cAAc,UAAU,OAAO,KAAK,GACtC;AAED,MAAI,cAAc,GAChB,OAAM,IAAI,MAAM,kCAAkC;AAGpD,OAAK,MAAM,MAAM,aAAa;GAAE,GAAG,KAAK,MAAM,MAAM;GAAY,GAAG;GAAM;AAEzE,OAAK,kBAAkB,kBAAkB,KAAK,MAAM;AACpD,SAAO,KAAK,MAAM,MAAM;;CAG1B,aAAa,OAAsB;AACjC,OAAK,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskPipeline.js","names":[],"sources":["../../../src/core/TaskPipeline.ts"],"sourcesContent":["import type { StepExecutorContext, TaskResult } from '../types/execution.js'\nimport type { BaseStepExecutionTask } from './BaseStepExecutionTask.js'\n\nexport class TaskPipeline {\n private readonly tasks: BaseStepExecutionTask[]\n\n constructor(tasks: BaseStepExecutionTask[]) {\n this.tasks = tasks\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n for (const task of this.tasks) {\n const shouldRun = await task.shouldRun(context)\n if (!shouldRun) {\n continue\n }\n const result = await task.run(context)\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n if (result.context && typeof result.context === 'object') {\n Object.assign(context, result.context)\n }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;AAGA,IAAa,eAAb,MAA0B;CACxB;CAEA,YAAY,OAAgC;AAC1C,OAAK,QAAQ;;CAGf,MAAM,IAAI,SAAmD;AAC3D,OAAK,MAAM,QAAQ,KAAK,OAAO;AAE7B,OAAI,
|
|
1
|
+
{"version":3,"file":"TaskPipeline.js","names":[],"sources":["../../../src/core/TaskPipeline.ts"],"sourcesContent":["import type { StepExecutorContext, TaskResult } from '../types/execution.js'\nimport type { BaseStepExecutionTask } from './BaseStepExecutionTask.js'\n\nexport class TaskPipeline {\n private readonly tasks: BaseStepExecutionTask[]\n\n constructor(tasks: BaseStepExecutionTask[]) {\n this.tasks = tasks\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n for (const task of this.tasks) {\n const shouldRun = await task.shouldRun(context)\n if (!shouldRun) {\n continue\n }\n const result = await task.run(context)\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n if (result.context && typeof result.context === 'object') {\n Object.assign(context, result.context)\n }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;AAGA,IAAa,eAAb,MAA0B;CACxB;CAEA,YAAY,OAAgC;AAC1C,OAAK,QAAQ;;CAGf,MAAM,IAAI,SAAmD;AAC3D,OAAK,MAAM,QAAQ,KAAK,OAAO;AAE7B,OAAI,CAAC,MADmB,KAAK,UAAU,QAAQ,CAE7C;GAEF,MAAM,SAAS,MAAM,KAAK,IAAI,QAAQ;AACtC,OAAI,OAAO,WAAW,SACpB,QAAO,EAAE,QAAQ,UAAU;AAE7B,OAAI,OAAO,WAAW,OAAO,OAAO,YAAY,SAC9C,QAAO,OAAO,SAAS,OAAO,QAAQ;;AAI1C,SAAO,EAAE,QAAQ,aAAa"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
require("../errors/constants.js");
|
|
3
3
|
const require_errors_errors = require("../errors/errors.js");
|
|
4
4
|
const require_core_executionState = require("./executionState.js");
|
|
5
5
|
const require_core_prepareRestart = require("./prepareRestart.js");
|
|
@@ -62,7 +62,7 @@ const executeSteps = async (client, route) => {
|
|
|
62
62
|
const fromAddress = step.action.fromAddress;
|
|
63
63
|
if (!fromAddress) throw new Error("Action fromAddress is not specified.");
|
|
64
64
|
const provider = client.providers.find((provider) => provider.isAddress(fromAddress));
|
|
65
|
-
if (!provider) throw new require_errors_errors.ProviderError(
|
|
65
|
+
if (!provider) throw new require_errors_errors.ProviderError(1005, "SDK Execution Provider not found.");
|
|
66
66
|
const stepExecutor = await provider.getStepExecutor({
|
|
67
67
|
routeId: route.id,
|
|
68
68
|
executionOptions: execution.executionOptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","names":["executionState","ProviderError","
|
|
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,MAAM;CAEjD,IAAI,mBAAmBA,4BAAAA,eAAe,IAAI,YAAY,GAAG,EAAE;AAE3D,KAAI,iBACF,QAAO;AAGT,6BAAA,eAAe,OAAO;EAAE,OAAO;EAAa;EAAkB,CAAC;AAC/D,oBAAmB,aAAa,QAAQ,YAAY;AACpD,6BAAA,eAAe,OAAO;EACpB,OAAO;EACP,SAAS;EACV,CAAC;AAEF,QAAO;;;;;;;;;;AAWT,MAAa,cAAc,OACzB,QACA,OACA,qBAC2B;CAC3B,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,GAAG;AAE9C,KAAI;MAIE,CAHoB,UAAU,UAAU,MACzC,aAAa,CAAC,SAAS,eAEN,EAAE;AAEpB,wBAAqB,OAAO,EAC1B,qBAAqB,kBAAkB,qBACxC,CAAC;AACF,OAAI,CAAC,UAAU,QAEb,OAAM,IAAI,MAAM,qCAAqC;AAEvD,UAAO,UAAU;;;AAIrB,6BAAA,eAAe,MAAM;AAErB,QAAO,aAAa,QAAQ,OAAO,iBAAiB;;AAGtD,MAAM,eAAe,OACnB,QACA,UAC2B;AAE3B,MAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,QAAQ,SAAS;EACvD,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,GAAG;AAE9C,MAAI,CAAC,UACH;EAGF,MAAM,OAAO,MAAM,MAAM;EACzB,MAAM,eAAe,MAAM,MAAM,QAAQ;AAEzC,MAAI,KAAK,WAAW,WAAW,OAC7B;AAIF,MAAI,cAAc,WAAW,UAAU;AACrC,QAAK,OAAO,aAAa,aAAa,UAAU;AAChD,OAAI,KAAK,eAAe,OACtB,MAAK,cAAc,GAAG,OAAO,aAC3B,aAAa,UAAU;;AAI7B,MAAI;GACF,MAAM,cAAc,KAAK,OAAO;AAChC,OAAI,CAAC,YACH,OAAM,IAAI,MAAM,uCAAuC;GAGzD,MAAM,WAAW,OAAO,UAAU,MAAM,aACtC,SAAS,UAAU,YAAY,CAChC;AAED,OAAI,CAAC,SACH,OAAM,IAAIC,sBAAAA,cAAAA,MAER,oCACD;GAGH,MAAM,eAAe,MAAM,SAAS,gBAAgB;IAClD,SAAS,MAAM;IACf,kBAAkB,UAAU;IAC7B,CAAC;AACF,aAAU,UAAU,KAAK,aAAa;AAGtC,OAAI,UAAU,iBACZ,sBAAqB,OAAO,UAAU,iBAAiB;GAGzD,IAAI;AACJ,OAAI;AACF,mBAAe,MAAM,aAAa,YAAY,QAAQ,KAAK;YACpD,GAAG;AACV,QAAI,aAAaC,sBAAAA,uBAAuB;AACtC,UAAK,YAAY,KAAA;AACjB,oBAAe,MAAM,aAAa,YAChC,QACA,MACA,EAAE,YACH;UAED,OAAM;;AAKV,OAAI,aAAa,WAAW,WAAW,OACrC,oBAAmB,MAAM;AAI3B,OAAI,CAAC,aAAa,eAChB,QAAO;WAEF,GAAG;AACV,sBAAmB,MAAM;AACzB,SAAM;;;AAKV,6BAAA,eAAe,OAAO,MAAM,GAAG;AAC/B,QAAO;;;;;;;AAQT,MAAa,wBACX,OACA,YACS;CACT,MAAM,YAAYF,4BAAAA,eAAe,IAAI,MAAM,GAAG;AAC9C,KAAI,CAAC,UACH;AAGF,KAAI,yBAAyB,QAC3B,MAAK,MAAM,YAAY,UAAU,UAC/B,UAAS,eAAe;EACtB,kBAAkB,CAAC,SAAS;EAC5B,cAAc;EACf,CAAC;AAIN,WAAU,mBAAmB;EAC3B,GAAG,UAAU;EACb,GAAG;EACJ;;;;;;;AAQH,MAAa,sBAAsB,UAAwB;CACzD,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,GAAG;AAC9C,KAAI,CAAC,UACH,QAAO;AAGT,MAAK,MAAM,YAAY,UAAU,UAC/B,UAAS,eAAe;EACtB,kBAAkB;EAClB,cAAc;EACd,gBAAgB;EACjB,CAAC;AAEJ,6BAAA,eAAe,OAAO,MAAM,GAAG;AAC/B,QAAO,UAAU;;;;;;AAOnB,MAAa,wBAAyC;AACpD,QAAO,OAAO,OAAOA,4BAAAA,eAAe,MAAM,CACvC,KAAK,SAAS,MAAM,MAAM,CAC1B,OAAO,QAAQ;;;;;;;AAQpB,MAAa,kBAAkB,YAA+C;AAC5E,QAAOA,4BAAAA,eAAe,IAAI,QAAQ,EAAE"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { StepExecutorContext, TaskResult } from "../../types/execution.js";
|
|
2
2
|
import { BaseStepExecutionTask } from "../BaseStepExecutionTask.js";
|
|
3
|
+
import { CheckBalanceOptions } from "./helpers/checkBalance.js";
|
|
3
4
|
|
|
4
5
|
//#region src/core/tasks/CheckBalanceTask.d.ts
|
|
5
6
|
declare class CheckBalanceTask extends BaseStepExecutionTask {
|
|
7
|
+
/**
|
|
8
|
+
* Per-step options hook for chain-specific subclasses (e.g. skip the
|
|
9
|
+
* gas check for smart-contract wallets or relayed steps). Default `{}`
|
|
10
|
+
* keeps behavior unchanged for every provider that doesn't override.
|
|
11
|
+
* Resolved lazily inside `run()` — pipelines that resume past
|
|
12
|
+
* `CheckBalance` pay no cost.
|
|
13
|
+
*/
|
|
14
|
+
protected getCheckBalanceOptions(_context: StepExecutorContext): Promise<CheckBalanceOptions>;
|
|
6
15
|
run(context: StepExecutorContext): Promise<TaskResult>;
|
|
7
16
|
}
|
|
8
17
|
//#endregion
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
require("../../errors/constants.js");
|
|
3
3
|
const require_errors_errors = require("../../errors/errors.js");
|
|
4
4
|
const require_core_BaseStepExecutionTask = require("../BaseStepExecutionTask.js");
|
|
5
5
|
const require_core_tasks_helpers_checkBalance = require("./helpers/checkBalance.js");
|
|
6
6
|
//#region src/core/tasks/CheckBalanceTask.ts
|
|
7
7
|
var CheckBalanceTask = class extends require_core_BaseStepExecutionTask.BaseStepExecutionTask {
|
|
8
|
+
/**
|
|
9
|
+
* Per-step options hook for chain-specific subclasses (e.g. skip the
|
|
10
|
+
* gas check for smart-contract wallets or relayed steps). Default `{}`
|
|
11
|
+
* keeps behavior unchanged for every provider that doesn't override.
|
|
12
|
+
* Resolved lazily inside `run()` — pipelines that resume past
|
|
13
|
+
* `CheckBalance` pay no cost.
|
|
14
|
+
*/
|
|
15
|
+
getCheckBalanceOptions(_context) {
|
|
16
|
+
return Promise.resolve({});
|
|
17
|
+
}
|
|
8
18
|
async run(context) {
|
|
9
19
|
const { client, step, statusManager, isBridgeExecution } = context;
|
|
10
20
|
statusManager.initializeAction({
|
|
@@ -14,8 +24,8 @@ var CheckBalanceTask = class extends require_core_BaseStepExecutionTask.BaseStep
|
|
|
14
24
|
status: "STARTED"
|
|
15
25
|
});
|
|
16
26
|
const walletAddress = step.action.fromAddress;
|
|
17
|
-
if (!walletAddress) throw new require_errors_errors.TransactionError(
|
|
18
|
-
await require_core_tasks_helpers_checkBalance.checkBalance(client, walletAddress, step);
|
|
27
|
+
if (!walletAddress) throw new require_errors_errors.TransactionError(1e3, "The wallet address is undefined.");
|
|
28
|
+
await require_core_tasks_helpers_checkBalance.checkBalance(client, walletAddress, step, await this.getCheckBalanceOptions(context));
|
|
19
29
|
return { status: "COMPLETED" };
|
|
20
30
|
}
|
|
21
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckBalanceTask.js","names":["BaseStepExecutionTask","TransactionError","
|
|
1
|
+
{"version":3,"file":"CheckBalanceTask.js","names":["BaseStepExecutionTask","TransactionError","checkBalance"],"sources":["../../../../src/core/tasks/CheckBalanceTask.ts"],"sourcesContent":["import { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport {\n type CheckBalanceOptions,\n checkBalance,\n} from './helpers/checkBalance.js'\n\nexport class CheckBalanceTask extends BaseStepExecutionTask {\n /**\n * Per-step options hook for chain-specific subclasses (e.g. skip the\n * gas check for smart-contract wallets or relayed steps). Default `{}`\n * keeps behavior unchanged for every provider that doesn't override.\n * Resolved lazily inside `run()` — pipelines that resume past\n * `CheckBalance` pay no cost.\n */\n protected getCheckBalanceOptions(\n _context: StepExecutorContext\n ): Promise<CheckBalanceOptions> {\n return Promise.resolve({})\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const { client, step, statusManager, isBridgeExecution } = context\n\n statusManager.initializeAction({\n step,\n type: isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const walletAddress = step.action.fromAddress\n if (!walletAddress) {\n throw new TransactionError(\n LiFiErrorCode.InternalError,\n 'The wallet address is undefined.'\n )\n }\n\n const options = await this.getCheckBalanceOptions(context)\n await checkBalance(client, walletAddress, step, options)\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;;;;;AASA,IAAa,mBAAb,cAAsCA,mCAAAA,sBAAsB;;;;;;;;CAQ1D,uBACE,UAC8B;AAC9B,SAAO,QAAQ,QAAQ,EAAE,CAAC;;CAG5B,MAAM,IAAI,SAAmD;EAC3D,MAAM,EAAE,QAAQ,MAAM,eAAe,sBAAsB;AAE3D,gBAAc,iBAAiB;GAC7B;GACA,MAAM,oBAAoB,gBAAgB;GAC1C,SAAS,KAAK,OAAO;GACrB,QAAQ;GACT,CAAC;EAEF,MAAM,gBAAgB,KAAK,OAAO;AAClC,MAAI,CAAC,cACH,OAAM,IAAIC,sBAAAA,iBAAAA,KAER,mCACD;AAIH,QAAMC,wCAAAA,aAAa,QAAQ,eAAe,MAAM,MAD1B,KAAK,uBAAuB,QAAQ,CACF;AACxD,SAAO,EAAE,QAAQ,aAAa"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
require("../../errors/constants.js");
|
|
3
3
|
const require_errors_errors = require("../../errors/errors.js");
|
|
4
4
|
const require_actions_getStepTransaction = require("../../actions/getStepTransaction.js");
|
|
5
5
|
const require_core_BaseStepExecutionTask = require("../BaseStepExecutionTask.js");
|
|
@@ -9,7 +9,7 @@ var PrepareTransactionTask = class extends require_core_BaseStepExecutionTask.Ba
|
|
|
9
9
|
async run(context) {
|
|
10
10
|
const { client, step, statusManager, allowUserInteraction, executionOptions, isBridgeExecution } = context;
|
|
11
11
|
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
12
|
-
if (!action) throw new require_errors_errors.TransactionError(
|
|
12
|
+
if (!action) throw new require_errors_errors.TransactionError(1008, "Unable to prepare transaction. Action not found.");
|
|
13
13
|
if (!step.transactionRequest) {
|
|
14
14
|
const { execution, ...stepBase } = step;
|
|
15
15
|
const comparedStep = await require_core_tasks_helpers_stepComparison.stepComparison(statusManager, step, await require_actions_getStepTransaction.getStepTransaction(client, stepBase), allowUserInteraction, executionOptions);
|
|
@@ -18,7 +18,7 @@ var PrepareTransactionTask = class extends require_core_BaseStepExecutionTask.Ba
|
|
|
18
18
|
execution: step.execution
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
if (!step.transactionRequest?.data) throw new require_errors_errors.TransactionError(
|
|
21
|
+
if (!step.transactionRequest?.data) throw new require_errors_errors.TransactionError(1008, "Unable to prepare transaction. Transaction request data is not found.");
|
|
22
22
|
statusManager.updateAction(step, action.type, "ACTION_REQUIRED");
|
|
23
23
|
if (!allowUserInteraction) return { status: "PAUSED" };
|
|
24
24
|
return { status: "COMPLETED" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrepareTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","
|
|
1
|
+
{"version":3,"file":"PrepareTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","stepComparison","getStepTransaction"],"sources":["../../../../src/core/tasks/PrepareTransactionTask.ts"],"sourcesContent":["import { getStepTransaction } from '../../actions/getStepTransaction.js'\nimport { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport { stepComparison } from './helpers/stepComparison.js'\n\nexport class PrepareTransactionTask extends BaseStepExecutionTask {\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const {\n client,\n step,\n statusManager,\n allowUserInteraction,\n executionOptions,\n isBridgeExecution,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n if (!step.transactionRequest) {\n const { execution, ...stepBase } = step\n const updatedStep = await getStepTransaction(client, stepBase)\n const comparedStep = await stepComparison(\n statusManager,\n step,\n updatedStep,\n allowUserInteraction,\n executionOptions\n )\n Object.assign(step, {\n ...comparedStep,\n execution: step.execution,\n })\n }\n\n if (!step.transactionRequest?.data) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request data is not found.'\n )\n }\n\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,yBAAb,cAA4CA,mCAAAA,sBAAsB;CAChE,MAAM,IAAI,SAAmD;EAC3D,MAAM,EACJ,QACA,MACA,eACA,sBACA,kBACA,sBACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,OACrC;AAED,MAAI,CAAC,OACH,OAAM,IAAIC,sBAAAA,iBAAAA,MAER,mDACD;AAGH,MAAI,CAAC,KAAK,oBAAoB;GAC5B,MAAM,EAAE,WAAW,GAAG,aAAa;GAEnC,MAAM,eAAe,MAAMC,0CAAAA,eACzB,eACA,MACA,MAJwBC,mCAAAA,mBAAmB,QAAQ,SAAS,EAK5D,sBACA,iBACD;AACD,UAAO,OAAO,MAAM;IAClB,GAAG;IACH,WAAW,KAAK;IACjB,CAAC;;AAGJ,MAAI,CAAC,KAAK,oBAAoB,KAC5B,OAAM,IAAIF,sBAAAA,iBAAAA,MAER,wEACD;AAGH,gBAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;AAEhE,MAAI,CAAC,qBACH,QAAO,EAAE,QAAQ,UAAU;AAG7B,SAAO,EAAE,QAAQ,aAAa"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
require("../../errors/constants.js");
|
|
3
3
|
const require_errors_errors = require("../../errors/errors.js");
|
|
4
4
|
const require_core_BaseStepExecutionTask = require("../BaseStepExecutionTask.js");
|
|
5
5
|
const require_utils_getTransactionMessage = require("../../utils/getTransactionMessage.js");
|
|
@@ -53,7 +53,7 @@ var WaitForTransactionStatusTask = class extends require_core_BaseStepExecutionT
|
|
|
53
53
|
return { status: "COMPLETED" };
|
|
54
54
|
} catch (e) {
|
|
55
55
|
const htmlMessage = await require_utils_getTransactionMessage.getTransactionFailedMessage(client, step, `${toChain.metamask.blockExplorerUrls[0]}tx/${transactionHash}`);
|
|
56
|
-
throw new require_errors_errors.TransactionError(
|
|
56
|
+
throw new require_errors_errors.TransactionError(1003, htmlMessage ?? "Failed while waiting for status of destination chain transaction.", e);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
};
|