@lifi/sdk 0.0.0-preview-c7217047 → 0.0.0-preview-479fb196

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/CHANGELOG.md CHANGED
@@ -1,10 +1,32 @@
1
1
  # @lifi/sdk
2
2
 
3
- ## 0.0.0-preview-c7217047
3
+ ## 0.0.0-preview-479fb196
4
+
5
+ ### Patch Changes
6
+
7
+ - [#488](https://github.com/lifinance/sdk/pull/488) [`2e34f09`](https://github.com/lifinance/sdk/commit/2e34f092aadc8e96494b3a625d6c6f75a1cf2cfe) Thanks [@chybisov](https://github.com/chybisov)! - Fix `client.extend()` dropping the `config` and `providers` accessors.
8
+
9
+ `extend` built the extended object with a shallow spread, which evaluates
10
+ getters and writes their current values as plain data properties. Because
11
+ `setProviders` reassigns the backing array, an extended client was frozen on
12
+ whatever the provider list happened to be at extend time — so a host that
13
+ extended before registering its wallet providers got a client that could
14
+ never execute, and `getProvider` always returned `undefined`.
15
+
16
+ Copy property descriptors instead, so the base and every extension share one
17
+ live view of the client's config and providers.
18
+
19
+ ## 4.8.1
20
+
21
+ ### Patch Changes
22
+
23
+ - [#486](https://github.com/lifinance/sdk/pull/486) [`621d410`](https://github.com/lifinance/sdk/commit/621d410db320188677df50f5ec5bf4a1c65bf818) Thanks [@chybisov](https://github.com/chybisov)! - Export `name` and `version` from the package entrypoint. The generated `src/version.ts` already carried the package name and the version that the SDK sends in its request headers and attaches to `SDKError`, but only internal modules could read them. Consumers can now import the same values instead of duplicating a hardcoded version string or reading `package.json` at runtime.
24
+
25
+ ## 4.8.0
4
26
 
5
27
  ### Minor Changes
6
28
 
7
- - [#475](https://github.com/lifinance/sdk/pull/475) [`e371b7f`](https://github.com/lifinance/sdk/commit/e371b7f8c8375dc32fe5b2122dbab2f634efd625) Thanks [@chybisov](https://github.com/chybisov)! - Bump the `@lifi/types` pin to `^18.6.0`.
29
+ - [#475](https://github.com/lifinance/sdk/pull/475) [`252a06d`](https://github.com/lifinance/sdk/commit/252a06de1db75fad3d8501e05cc128b0a4c9d914) Thanks [@chybisov](https://github.com/chybisov)! - Bump the `@lifi/types` pin to `^18.10.0`.
8
30
 
9
31
  `18.6.0` adds `PermitSingle` to `TypedDataPrimaryTypes`, so the Ethereum
10
32
  provider's typed-data lane classifier can compare `primaryType` against the
@@ -13,6 +35,15 @@
13
35
  `@lifi/sdk` re-exports `@lifi/types` wholesale, so the addition widens its own
14
36
  public type surface — additive only, nothing is removed or narrowed.
15
37
 
38
+ ### Patch Changes
39
+
40
+ - [#484](https://github.com/lifinance/sdk/pull/484) [`13c19c4`](https://github.com/lifinance/sdk/commit/13c19c4441341683b9dbaa8943e950b8f7571304) Thanks [@chybisov](https://github.com/chybisov)! - Refresh runtime dependencies: `@lifi/types` to `^18.10.0`, `viem` to `^2.56.8`,
41
+ `@mysten/sui` to `^2.31.3`, `@solana/kit` to `^8.3.0`,
42
+ `@solana/wallet-standard-features` to `^1.5.0`, `@stellar/stellar-sdk` to `^17.1.0`,
43
+ `@bigmi/core` to `^0.9.2` and `tronweb` to `^6.5.1`.
44
+
45
+ - [#475](https://github.com/lifinance/sdk/pull/475) [`252a06d`](https://github.com/lifinance/sdk/commit/252a06de1db75fad3d8501e05cc128b0a4c9d914) Thanks [@chybisov](https://github.com/chybisov)! - Give a pending bridge a link to follow. While waiting for the destination, the status poll only forwarded `bridgeExplorerLink`, which most bridges do not provide, so the receiving action had nothing to open for the whole wait. It now falls back to `lifiExplorerLink`, which every recorded transfer carries and which shows both legs.
46
+
16
47
  ## 4.7.0
17
48
 
18
49
  ### Minor Changes
@@ -55,10 +55,10 @@ function createClient(options) {
55
55
  function extend(base) {
56
56
  return (extendFn) => {
57
57
  const extensions = extendFn(base);
58
- const extended = {
59
- ...base,
60
- ...extensions
61
- };
58
+ const extended = Object.defineProperties({}, {
59
+ ...Object.getOwnPropertyDescriptors(base),
60
+ ...Object.getOwnPropertyDescriptors(extensions)
61
+ });
62
62
  return Object.assign(extended, { extend: extend(extended) });
63
63
  };
64
64
  }
@@ -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;CAC1D,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,MACR,yGACF;CAGF,IAAI,CAAC,QAAQ,uBAAuB,QAAQ,IAAI,aAAa,eAC3D,kCAAA,oBAAoBA,gBAAAA,MAAMC,gBAAAA,OAAO;CAGnC,MAAM,EAAE,WAAW,GAAG,kBAAkB;CAExC,MAAM,UAAyB;EAC7B,GAAG;EACH,QAAQ,eAAe,UAAU;EACjC,SAAS,eAAe,WAAW,CAAC;EACpC,OAAO,eAAe,SAAS;EAC/B,eAAe,eAAe,iBAAiB;EAC/C,YAAY,eAAe,cAAc;CAC3C;CAEA,IAAI,aAA4B,aAAa,CAAC;CAC9C,MAAM,WAAWC,gCAAAA,iBAAiB,OAAO;CAEzC,MAAM,SAAoB;EACxB,IAAI,SAAS;GACX,OAAO;EACT;EACA,IAAI,YAAY;GACd,OAAO;EACT;EACA,YAAY,MAAiB;GAC3B,OAAO,KAAK,UAAU,MAAM,aAAa,SAAS,SAAS,IAAI;EACjE;EACA,aAAa,cAA6B;GACxC,MAAM,cAAc,IAAI,IACtB,KAAK,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,QAAQ,CAAC,CAC5D;GACA,KAAK,MAAM,YAAY,cACrB,YAAY,IAAI,SAAS,MAAM,QAAQ;GAEzC,aAAa,MAAM,KAAK,YAAY,OAAO,CAAC;EAC9C;EACA,UAAU,QAAyB;GACjC,SAAS,UAAU,MAAM;EAC3B;EACA,MAAM,YAAY;GAChB,OAAO,MAAM,SAAS,UAAU;EAClC;EACA,MAAM,aAAa,SAAkB;GAEnC,MAAM,SAAQ,MADO,KAAK,UAAU,EAAA,EACd,MAAM,UAAU,MAAM,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,WAAW,QAAQ,WAAW;GAEhD,OAAO;EACT;EACA,MAAM,aAAa;GACjB,OAAO,MAAM,SAAS,WAAW;EACnC;EACA,MAAM,oBAAoB,SAAkB;GAE1C,MAAM,gBAAe,MADC,KAAK,WAAW,EAAA,CACT;GAC7B,IAAI,CAAC,cAAc,QACjB,MAAM,IAAI,MAAM,kCAAkC,SAAS;GAE7D,OAAO;EACT;CACF;CAEA,SAAS,OACP,MAGyB;EACzB,QAAQ,aAAa;GACnB,MAAM,aAAa,SAAS,IAAI;GAChC,MAAM,WAAW;IAAE,GAAG;IAAM,GAAG;GAAW;GAG1C,OAAO,OAAO,OAAO,UAAU,EAC7B,QAAQ,OAAO,QAAQ,EACzB,CAAC;EACH;CACF;CAEA,OAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAE,CAAC;AACzD"}
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 // Copy descriptors rather than spreading. `config` and `providers` are\n // accessors over closure variables, and `setProviders` reassigns\n // `_providers` — so a spread would freeze the extension on the values\n // those getters happened to return at extend time, leaving it with a\n // provider list that never updates.\n const extended = Object.defineProperties(\n {},\n {\n ...Object.getOwnPropertyDescriptors(base),\n ...Object.getOwnPropertyDescriptors(extensions),\n }\n ) 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;CAC1D,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,MACR,yGACF;CAGF,IAAI,CAAC,QAAQ,uBAAuB,QAAQ,IAAI,aAAa,eAC3D,kCAAA,oBAAoBA,gBAAAA,MAAMC,gBAAAA,OAAO;CAGnC,MAAM,EAAE,WAAW,GAAG,kBAAkB;CAExC,MAAM,UAAyB;EAC7B,GAAG;EACH,QAAQ,eAAe,UAAU;EACjC,SAAS,eAAe,WAAW,CAAC;EACpC,OAAO,eAAe,SAAS;EAC/B,eAAe,eAAe,iBAAiB;EAC/C,YAAY,eAAe,cAAc;CAC3C;CAEA,IAAI,aAA4B,aAAa,CAAC;CAC9C,MAAM,WAAWC,gCAAAA,iBAAiB,OAAO;CAEzC,MAAM,SAAoB;EACxB,IAAI,SAAS;GACX,OAAO;EACT;EACA,IAAI,YAAY;GACd,OAAO;EACT;EACA,YAAY,MAAiB;GAC3B,OAAO,KAAK,UAAU,MAAM,aAAa,SAAS,SAAS,IAAI;EACjE;EACA,aAAa,cAA6B;GACxC,MAAM,cAAc,IAAI,IACtB,KAAK,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,QAAQ,CAAC,CAC5D;GACA,KAAK,MAAM,YAAY,cACrB,YAAY,IAAI,SAAS,MAAM,QAAQ;GAEzC,aAAa,MAAM,KAAK,YAAY,OAAO,CAAC;EAC9C;EACA,UAAU,QAAyB;GACjC,SAAS,UAAU,MAAM;EAC3B;EACA,MAAM,YAAY;GAChB,OAAO,MAAM,SAAS,UAAU;EAClC;EACA,MAAM,aAAa,SAAkB;GAEnC,MAAM,SAAQ,MADO,KAAK,UAAU,EAAA,EACd,MAAM,UAAU,MAAM,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,WAAW,QAAQ,WAAW;GAEhD,OAAO;EACT;EACA,MAAM,aAAa;GACjB,OAAO,MAAM,SAAS,WAAW;EACnC;EACA,MAAM,oBAAoB,SAAkB;GAE1C,MAAM,gBAAe,MADC,KAAK,WAAW,EAAA,CACT;GAC7B,IAAI,CAAC,cAAc,QACjB,MAAM,IAAI,MAAM,kCAAkC,SAAS;GAE7D,OAAO;EACT;CACF;CAEA,SAAS,OACP,MAGyB;EACzB,QAAQ,aAAa;GACnB,MAAM,aAAa,SAAS,IAAI;GAMhC,MAAM,WAAW,OAAO,iBACtB,CAAC,GACD;IACE,GAAG,OAAO,0BAA0B,IAAI;IACxC,GAAG,OAAO,0BAA0B,UAAU;GAChD,CACF;GAGA,OAAO,OAAO,OAAO,UAAU,EAC7B,QAAQ,OAAO,QAAQ,EACzB,CAAC;EACH;CACF;CAEA,OAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAE,CAAC;AACzD"}
@@ -17,13 +17,15 @@ async function waitForTransactionStatus(client, statusManager, txHash, step, act
17
17
  }).then((statusResponse) => {
18
18
  switch (statusResponse.status) {
19
19
  case "DONE": return statusResponse;
20
- case "PENDING":
20
+ case "PENDING": {
21
+ const pendingStatus = statusResponse;
21
22
  statusManager?.updateAction(step, actionType, "PENDING", {
22
23
  substatus: statusResponse.substatus,
23
24
  substatusMessage: statusResponse.substatusMessage || require_core_actionMessages.getSubstatusMessage(statusResponse.status, statusResponse.substatus),
24
- txLink: statusResponse.bridgeExplorerLink
25
+ txLink: pendingStatus.bridgeExplorerLink ?? pendingStatus.lifiExplorerLink
25
26
  });
26
27
  return;
28
+ }
27
29
  case "NOT_FOUND": return;
28
30
  default: return Promise.reject();
29
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"waitForTransactionStatus.js","names":["getStatus","getSubstatusMessage","waitForResult","ServerError"],"sources":["../../../../../src/core/tasks/helpers/waitForTransactionStatus.ts"],"sourcesContent":["import type { FullStatusData, LiFiStep, StatusResponse } from '@lifi/types'\nimport { getStatus } from '../../../actions/getStatus.js'\nimport { ServerError } from '../../../errors/errors.js'\nimport type { ExecutionActionType, SDKClient } from '../../../types/core.js'\nimport { waitForResult } from '../../../utils/waitForResult.js'\nimport { getSubstatusMessage } from '../../actionMessages.js'\nimport type { StatusManager } from '../../StatusManager.js'\n\nconst TRANSACTION_HASH_OBSERVERS: Record<string, Promise<StatusResponse>> = {}\n\nexport async function waitForTransactionStatus(\n client: SDKClient,\n statusManager: StatusManager,\n txHash: string,\n step: LiFiStep,\n actionType: ExecutionActionType,\n interval = 5_000\n): Promise<StatusResponse> {\n const _getStatus = (): Promise<StatusResponse | undefined> => {\n return getStatus(client, {\n fromChain: step.action.fromChainId,\n fromAddress: step.action.fromAddress,\n toChain: step.action.toChainId,\n txHash,\n ...(step.tool !== 'custom' && { bridge: step.tool }),\n ...(step.transactionId && { transactionId: step.transactionId }),\n })\n .then((statusResponse) => {\n switch (statusResponse.status) {\n case 'DONE':\n return statusResponse\n case 'PENDING':\n statusManager?.updateAction(step, actionType, 'PENDING', {\n substatus: statusResponse.substatus,\n substatusMessage:\n statusResponse.substatusMessage ||\n getSubstatusMessage(\n statusResponse.status,\n statusResponse.substatus\n ),\n txLink: (statusResponse as FullStatusData).bridgeExplorerLink,\n })\n return undefined\n case 'NOT_FOUND':\n return undefined\n default:\n return Promise.reject()\n }\n })\n .catch((e) => {\n if (process.env.NODE_ENV === 'development') {\n console.debug('Fetching status from backend failed.', e)\n }\n return undefined\n })\n }\n\n let status = TRANSACTION_HASH_OBSERVERS[txHash]\n\n if (!status) {\n status = waitForResult(_getStatus, interval).finally(() => {\n delete TRANSACTION_HASH_OBSERVERS[txHash]\n })\n TRANSACTION_HASH_OBSERVERS[txHash] = status\n }\n\n const resolvedStatus = await status\n\n if (!('receiving' in resolvedStatus)) {\n throw new ServerError(\n \"Status doesn't contain destination chain information.\"\n )\n }\n\n return resolvedStatus\n}\n"],"mappings":";;;;;;AAQA,MAAM,6BAAsE,CAAC;AAE7E,eAAsB,yBACpB,QACA,eACA,QACA,MACA,YACA,WAAW,KACc;CACzB,MAAM,mBAAwD;EAC5D,OAAOA,0BAAAA,UAAU,QAAQ;GACvB,WAAW,KAAK,OAAO;GACvB,aAAa,KAAK,OAAO;GACzB,SAAS,KAAK,OAAO;GACrB;GACA,GAAI,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,KAAK;GAClD,GAAI,KAAK,iBAAiB,EAAE,eAAe,KAAK,cAAc;EAChE,CAAC,CAAC,CACC,MAAM,mBAAmB;GACxB,QAAQ,eAAe,QAAvB;IACE,KAAK,QACH,OAAO;IACT,KAAK;KACH,eAAe,aAAa,MAAM,YAAY,WAAW;MACvD,WAAW,eAAe;MAC1B,kBACE,eAAe,oBACfC,4BAAAA,oBACE,eAAe,QACf,eAAe,SACjB;MACF,QAAS,eAAkC;KAC7C,CAAC;KACD;IACF,KAAK,aACH;IACF,SACE,OAAO,QAAQ,OAAO;GAC1B;EACF,CAAC,CAAC,CACD,OAAO,MAAM;GACZ,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;CACL;CAEA,IAAI,SAAS,2BAA2B;CAExC,IAAI,CAAC,QAAQ;EACX,SAASC,4BAAAA,cAAc,YAAY,QAAQ,CAAC,CAAC,cAAc;GACzD,OAAO,2BAA2B;EACpC,CAAC;EACD,2BAA2B,UAAU;CACvC;CAEA,MAAM,iBAAiB,MAAM;CAE7B,IAAI,EAAE,eAAe,iBACnB,MAAM,IAAIC,sBAAAA,YACR,uDACF;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"waitForTransactionStatus.js","names":["getStatus","getSubstatusMessage","waitForResult","ServerError"],"sources":["../../../../../src/core/tasks/helpers/waitForTransactionStatus.ts"],"sourcesContent":["import type { FullStatusData, LiFiStep, StatusResponse } from '@lifi/types'\nimport { getStatus } from '../../../actions/getStatus.js'\nimport { ServerError } from '../../../errors/errors.js'\nimport type { ExecutionActionType, SDKClient } from '../../../types/core.js'\nimport { waitForResult } from '../../../utils/waitForResult.js'\nimport { getSubstatusMessage } from '../../actionMessages.js'\nimport type { StatusManager } from '../../StatusManager.js'\n\nconst TRANSACTION_HASH_OBSERVERS: Record<string, Promise<StatusResponse>> = {}\n\nexport async function waitForTransactionStatus(\n client: SDKClient,\n statusManager: StatusManager,\n txHash: string,\n step: LiFiStep,\n actionType: ExecutionActionType,\n interval = 5_000\n): Promise<StatusResponse> {\n const _getStatus = (): Promise<StatusResponse | undefined> => {\n return getStatus(client, {\n fromChain: step.action.fromChainId,\n fromAddress: step.action.fromAddress,\n toChain: step.action.toChainId,\n txHash,\n ...(step.tool !== 'custom' && { bridge: step.tool }),\n ...(step.transactionId && { transactionId: step.transactionId }),\n })\n .then((statusResponse) => {\n switch (statusResponse.status) {\n case 'DONE':\n return statusResponse\n case 'PENDING': {\n const pendingStatus = statusResponse as FullStatusData\n statusManager?.updateAction(step, actionType, 'PENDING', {\n substatus: statusResponse.substatus,\n substatusMessage:\n statusResponse.substatusMessage ||\n getSubstatusMessage(\n statusResponse.status,\n statusResponse.substatus\n ),\n // Most bridges implement no `getExplorerLink`, so fall back to\n // the LI.FI explorer rather than leave the user with no link.\n txLink:\n pendingStatus.bridgeExplorerLink ??\n pendingStatus.lifiExplorerLink,\n })\n return undefined\n }\n case 'NOT_FOUND':\n return undefined\n default:\n return Promise.reject()\n }\n })\n .catch((e) => {\n if (process.env.NODE_ENV === 'development') {\n console.debug('Fetching status from backend failed.', e)\n }\n return undefined\n })\n }\n\n let status = TRANSACTION_HASH_OBSERVERS[txHash]\n\n if (!status) {\n status = waitForResult(_getStatus, interval).finally(() => {\n delete TRANSACTION_HASH_OBSERVERS[txHash]\n })\n TRANSACTION_HASH_OBSERVERS[txHash] = status\n }\n\n const resolvedStatus = await status\n\n if (!('receiving' in resolvedStatus)) {\n throw new ServerError(\n \"Status doesn't contain destination chain information.\"\n )\n }\n\n return resolvedStatus\n}\n"],"mappings":";;;;;;AAQA,MAAM,6BAAsE,CAAC;AAE7E,eAAsB,yBACpB,QACA,eACA,QACA,MACA,YACA,WAAW,KACc;CACzB,MAAM,mBAAwD;EAC5D,OAAOA,0BAAAA,UAAU,QAAQ;GACvB,WAAW,KAAK,OAAO;GACvB,aAAa,KAAK,OAAO;GACzB,SAAS,KAAK,OAAO;GACrB;GACA,GAAI,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,KAAK;GAClD,GAAI,KAAK,iBAAiB,EAAE,eAAe,KAAK,cAAc;EAChE,CAAC,CAAC,CACC,MAAM,mBAAmB;GACxB,QAAQ,eAAe,QAAvB;IACE,KAAK,QACH,OAAO;IACT,KAAK,WAAW;KACd,MAAM,gBAAgB;KACtB,eAAe,aAAa,MAAM,YAAY,WAAW;MACvD,WAAW,eAAe;MAC1B,kBACE,eAAe,oBACfC,4BAAAA,oBACE,eAAe,QACf,eAAe,SACjB;MAGF,QACE,cAAc,sBACd,cAAc;KAClB,CAAC;KACD;IACF;IACA,KAAK,aACH;IACF,SACE,OAAO,QAAQ,OAAO;GAC1B;EACF,CAAC,CAAC,CACD,OAAO,MAAM;GACZ,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;CACL;CAEA,IAAI,SAAS,2BAA2B;CAExC,IAAI,CAAC,QAAQ;EACX,SAASC,4BAAAA,cAAc,YAAY,QAAQ,CAAC,CAAC,cAAc;GACzD,OAAO,2BAA2B;EACpC,CAAC;EACD,2BAA2B,UAAU;CACvC;CAEA,MAAM,iBAAiB,MAAM;CAE7B,IAAI,EAAE,eAAe,iBACnB,MAAM,IAAIC,sBAAAA,YACR,uDACF;CAGF,OAAO;AACT"}
@@ -51,5 +51,6 @@ import { sleep } from "./utils/sleep.js";
51
51
  import { waitForResult } from "./utils/waitForResult.js";
52
52
  import { LruMap, withDedupe } from "./utils/withDedupe.js";
53
53
  import { withTimeout } from "./utils/withTimeout.js";
54
+ import { name, version } from "./version.js";
54
55
  export * from "@lifi/types";
55
- export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
56
+ export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
package/dist/cjs/index.js CHANGED
@@ -3,6 +3,7 @@ const require_errors_baseError = require("./errors/baseError.js");
3
3
  const require_errors_constants = require("./errors/constants.js");
4
4
  const require_errors_errors = require("./errors/errors.js");
5
5
  const require_errors_httpError = require("./errors/httpError.js");
6
+ const require_version = require("./version.js");
6
7
  const require_errors_SDKError = require("./errors/SDKError.js");
7
8
  const require_utils_sleep = require("./utils/sleep.js");
8
9
  const require_utils_withDedupe = require("./utils/withDedupe.js");
@@ -106,6 +107,7 @@ exports.getTools = require_actions_getTools.getTools;
106
107
  exports.getTransactionHistory = require_actions_getTransactionHistory.getTransactionHistory;
107
108
  exports.getTransactionRequestData = require_core_tasks_helpers_getTransactionRequestData.getTransactionRequestData;
108
109
  exports.isHex = require_utils_isHex.isHex;
110
+ exports.name = require_version.name;
109
111
  exports.parseUnits = require_utils_parseUnits.parseUnits;
110
112
  exports.patchContractCalls = require_actions_patchContractCalls.patchContractCalls;
111
113
  exports.relayTransaction = require_actions_relayTransaction.relayTransaction;
@@ -114,6 +116,7 @@ exports.sleep = require_utils_sleep.sleep;
114
116
  exports.stepComparison = require_core_tasks_helpers_stepComparison.stepComparison;
115
117
  exports.stopRouteExecution = require_core_execution.stopRouteExecution;
116
118
  exports.updateRouteExecution = require_core_execution.updateRouteExecution;
119
+ exports.version = require_version.version;
117
120
  exports.waitForResult = require_utils_waitForResult.waitForResult;
118
121
  exports.withDedupe = require_utils_withDedupe.withDedupe;
119
122
  exports.withTimeout = require_utils_withTimeout.withTimeout;
@@ -5,7 +5,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
5
5
  try {
6
6
  const pkgName = packageName ?? "@lifi/sdk";
7
7
  const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
8
- const currentVersion = packageVersion ?? "0.0.0-preview-c7217047";
8
+ const currentVersion = packageVersion ?? "0.0.0-preview-479fb196";
9
9
  if (latestVersion > currentVersion) console.warn(`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
10
10
  } catch (_error) {}
11
11
  };
@@ -1,5 +1,5 @@
1
1
  //#region src/version.d.ts
2
2
  export declare const name = "@lifi/sdk";
3
- export declare const version = "0.0.0-preview-c7217047";
3
+ export declare const version = "0.0.0-preview-479fb196";
4
4
  //#endregion
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/version.ts
3
3
  const name = "@lifi/sdk";
4
- const version = "0.0.0-preview-c7217047";
4
+ const version = "0.0.0-preview-479fb196";
5
5
  //#endregion
6
6
  exports.name = name;
7
7
  exports.version = version;
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '0.0.0-preview-c7217047'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '0.0.0-preview-479fb196'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
@@ -54,10 +54,10 @@ function createClient(options) {
54
54
  function extend(base) {
55
55
  return (extendFn) => {
56
56
  const extensions = extendFn(base);
57
- const extended = {
58
- ...base,
59
- ...extensions
60
- };
57
+ const extended = Object.defineProperties({}, {
58
+ ...Object.getOwnPropertyDescriptors(base),
59
+ ...Object.getOwnPropertyDescriptors(extensions)
60
+ });
61
61
  return Object.assign(extended, { extend: extend(extended) });
62
62
  };
63
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.js","names":[],"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;CAC1D,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,MACR,yGACF;CAGF,IAAI,CAAC,QAAQ,uBAAuB,QAAQ,IAAI,aAAa,eAC3D,oBAAoB,MAAM,OAAO;CAGnC,MAAM,EAAE,WAAW,GAAG,kBAAkB;CAExC,MAAM,UAAyB;EAC7B,GAAG;EACH,QAAQ,eAAe,UAAU;EACjC,SAAS,eAAe,WAAW,CAAC;EACpC,OAAO,eAAe,SAAS;EAC/B,eAAe,eAAe,iBAAiB;EAC/C,YAAY,eAAe,cAAc;CAC3C;CAEA,IAAI,aAA4B,aAAa,CAAC;CAC9C,MAAM,WAAW,iBAAiB,OAAO;CAEzC,MAAM,SAAoB;EACxB,IAAI,SAAS;GACX,OAAO;EACT;EACA,IAAI,YAAY;GACd,OAAO;EACT;EACA,YAAY,MAAiB;GAC3B,OAAO,KAAK,UAAU,MAAM,aAAa,SAAS,SAAS,IAAI;EACjE;EACA,aAAa,cAA6B;GACxC,MAAM,cAAc,IAAI,IACtB,KAAK,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,QAAQ,CAAC,CAC5D;GACA,KAAK,MAAM,YAAY,cACrB,YAAY,IAAI,SAAS,MAAM,QAAQ;GAEzC,aAAa,MAAM,KAAK,YAAY,OAAO,CAAC;EAC9C;EACA,UAAU,QAAyB;GACjC,SAAS,UAAU,MAAM;EAC3B;EACA,MAAM,YAAY;GAChB,OAAO,MAAM,SAAS,UAAU;EAClC;EACA,MAAM,aAAa,SAAkB;GAEnC,MAAM,SAAQ,MADO,KAAK,UAAU,EAAA,EACd,MAAM,UAAU,MAAM,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,WAAW,QAAQ,WAAW;GAEhD,OAAO;EACT;EACA,MAAM,aAAa;GACjB,OAAO,MAAM,SAAS,WAAW;EACnC;EACA,MAAM,oBAAoB,SAAkB;GAE1C,MAAM,gBAAe,MADC,KAAK,WAAW,EAAA,CACT;GAC7B,IAAI,CAAC,cAAc,QACjB,MAAM,IAAI,MAAM,kCAAkC,SAAS;GAE7D,OAAO;EACT;CACF;CAEA,SAAS,OACP,MAGyB;EACzB,QAAQ,aAAa;GACnB,MAAM,aAAa,SAAS,IAAI;GAChC,MAAM,WAAW;IAAE,GAAG;IAAM,GAAG;GAAW;GAG1C,OAAO,OAAO,OAAO,UAAU,EAC7B,QAAQ,OAAO,QAAQ,EACzB,CAAC;EACH;CACF;CAEA,OAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAE,CAAC;AACzD"}
1
+ {"version":3,"file":"createClient.js","names":[],"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 // Copy descriptors rather than spreading. `config` and `providers` are\n // accessors over closure variables, and `setProviders` reassigns\n // `_providers` — so a spread would freeze the extension on the values\n // those getters happened to return at extend time, leaving it with a\n // provider list that never updates.\n const extended = Object.defineProperties(\n {},\n {\n ...Object.getOwnPropertyDescriptors(base),\n ...Object.getOwnPropertyDescriptors(extensions),\n }\n ) 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;CAC1D,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,MACR,yGACF;CAGF,IAAI,CAAC,QAAQ,uBAAuB,QAAQ,IAAI,aAAa,eAC3D,oBAAoB,MAAM,OAAO;CAGnC,MAAM,EAAE,WAAW,GAAG,kBAAkB;CAExC,MAAM,UAAyB;EAC7B,GAAG;EACH,QAAQ,eAAe,UAAU;EACjC,SAAS,eAAe,WAAW,CAAC;EACpC,OAAO,eAAe,SAAS;EAC/B,eAAe,eAAe,iBAAiB;EAC/C,YAAY,eAAe,cAAc;CAC3C;CAEA,IAAI,aAA4B,aAAa,CAAC;CAC9C,MAAM,WAAW,iBAAiB,OAAO;CAEzC,MAAM,SAAoB;EACxB,IAAI,SAAS;GACX,OAAO;EACT;EACA,IAAI,YAAY;GACd,OAAO;EACT;EACA,YAAY,MAAiB;GAC3B,OAAO,KAAK,UAAU,MAAM,aAAa,SAAS,SAAS,IAAI;EACjE;EACA,aAAa,cAA6B;GACxC,MAAM,cAAc,IAAI,IACtB,KAAK,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,QAAQ,CAAC,CAC5D;GACA,KAAK,MAAM,YAAY,cACrB,YAAY,IAAI,SAAS,MAAM,QAAQ;GAEzC,aAAa,MAAM,KAAK,YAAY,OAAO,CAAC;EAC9C;EACA,UAAU,QAAyB;GACjC,SAAS,UAAU,MAAM;EAC3B;EACA,MAAM,YAAY;GAChB,OAAO,MAAM,SAAS,UAAU;EAClC;EACA,MAAM,aAAa,SAAkB;GAEnC,MAAM,SAAQ,MADO,KAAK,UAAU,EAAA,EACd,MAAM,UAAU,MAAM,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,WAAW,QAAQ,WAAW;GAEhD,OAAO;EACT;EACA,MAAM,aAAa;GACjB,OAAO,MAAM,SAAS,WAAW;EACnC;EACA,MAAM,oBAAoB,SAAkB;GAE1C,MAAM,gBAAe,MADC,KAAK,WAAW,EAAA,CACT;GAC7B,IAAI,CAAC,cAAc,QACjB,MAAM,IAAI,MAAM,kCAAkC,SAAS;GAE7D,OAAO;EACT;CACF;CAEA,SAAS,OACP,MAGyB;EACzB,QAAQ,aAAa;GACnB,MAAM,aAAa,SAAS,IAAI;GAMhC,MAAM,WAAW,OAAO,iBACtB,CAAC,GACD;IACE,GAAG,OAAO,0BAA0B,IAAI;IACxC,GAAG,OAAO,0BAA0B,UAAU;GAChD,CACF;GAGA,OAAO,OAAO,OAAO,UAAU,EAC7B,QAAQ,OAAO,QAAQ,EACzB,CAAC;EACH;CACF;CAEA,OAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAE,CAAC;AACzD"}
@@ -16,13 +16,15 @@ async function waitForTransactionStatus(client, statusManager, txHash, step, act
16
16
  }).then((statusResponse) => {
17
17
  switch (statusResponse.status) {
18
18
  case "DONE": return statusResponse;
19
- case "PENDING":
19
+ case "PENDING": {
20
+ const pendingStatus = statusResponse;
20
21
  statusManager?.updateAction(step, actionType, "PENDING", {
21
22
  substatus: statusResponse.substatus,
22
23
  substatusMessage: statusResponse.substatusMessage || getSubstatusMessage(statusResponse.status, statusResponse.substatus),
23
- txLink: statusResponse.bridgeExplorerLink
24
+ txLink: pendingStatus.bridgeExplorerLink ?? pendingStatus.lifiExplorerLink
24
25
  });
25
26
  return;
27
+ }
26
28
  case "NOT_FOUND": return;
27
29
  default: return Promise.reject();
28
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"waitForTransactionStatus.js","names":[],"sources":["../../../../../src/core/tasks/helpers/waitForTransactionStatus.ts"],"sourcesContent":["import type { FullStatusData, LiFiStep, StatusResponse } from '@lifi/types'\nimport { getStatus } from '../../../actions/getStatus.js'\nimport { ServerError } from '../../../errors/errors.js'\nimport type { ExecutionActionType, SDKClient } from '../../../types/core.js'\nimport { waitForResult } from '../../../utils/waitForResult.js'\nimport { getSubstatusMessage } from '../../actionMessages.js'\nimport type { StatusManager } from '../../StatusManager.js'\n\nconst TRANSACTION_HASH_OBSERVERS: Record<string, Promise<StatusResponse>> = {}\n\nexport async function waitForTransactionStatus(\n client: SDKClient,\n statusManager: StatusManager,\n txHash: string,\n step: LiFiStep,\n actionType: ExecutionActionType,\n interval = 5_000\n): Promise<StatusResponse> {\n const _getStatus = (): Promise<StatusResponse | undefined> => {\n return getStatus(client, {\n fromChain: step.action.fromChainId,\n fromAddress: step.action.fromAddress,\n toChain: step.action.toChainId,\n txHash,\n ...(step.tool !== 'custom' && { bridge: step.tool }),\n ...(step.transactionId && { transactionId: step.transactionId }),\n })\n .then((statusResponse) => {\n switch (statusResponse.status) {\n case 'DONE':\n return statusResponse\n case 'PENDING':\n statusManager?.updateAction(step, actionType, 'PENDING', {\n substatus: statusResponse.substatus,\n substatusMessage:\n statusResponse.substatusMessage ||\n getSubstatusMessage(\n statusResponse.status,\n statusResponse.substatus\n ),\n txLink: (statusResponse as FullStatusData).bridgeExplorerLink,\n })\n return undefined\n case 'NOT_FOUND':\n return undefined\n default:\n return Promise.reject()\n }\n })\n .catch((e) => {\n if (process.env.NODE_ENV === 'development') {\n console.debug('Fetching status from backend failed.', e)\n }\n return undefined\n })\n }\n\n let status = TRANSACTION_HASH_OBSERVERS[txHash]\n\n if (!status) {\n status = waitForResult(_getStatus, interval).finally(() => {\n delete TRANSACTION_HASH_OBSERVERS[txHash]\n })\n TRANSACTION_HASH_OBSERVERS[txHash] = status\n }\n\n const resolvedStatus = await status\n\n if (!('receiving' in resolvedStatus)) {\n throw new ServerError(\n \"Status doesn't contain destination chain information.\"\n )\n }\n\n return resolvedStatus\n}\n"],"mappings":";;;;;AAQA,MAAM,6BAAsE,CAAC;AAE7E,eAAsB,yBACpB,QACA,eACA,QACA,MACA,YACA,WAAW,KACc;CACzB,MAAM,mBAAwD;EAC5D,OAAO,UAAU,QAAQ;GACvB,WAAW,KAAK,OAAO;GACvB,aAAa,KAAK,OAAO;GACzB,SAAS,KAAK,OAAO;GACrB;GACA,GAAI,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,KAAK;GAClD,GAAI,KAAK,iBAAiB,EAAE,eAAe,KAAK,cAAc;EAChE,CAAC,CAAC,CACC,MAAM,mBAAmB;GACxB,QAAQ,eAAe,QAAvB;IACE,KAAK,QACH,OAAO;IACT,KAAK;KACH,eAAe,aAAa,MAAM,YAAY,WAAW;MACvD,WAAW,eAAe;MAC1B,kBACE,eAAe,oBACf,oBACE,eAAe,QACf,eAAe,SACjB;MACF,QAAS,eAAkC;KAC7C,CAAC;KACD;IACF,KAAK,aACH;IACF,SACE,OAAO,QAAQ,OAAO;GAC1B;EACF,CAAC,CAAC,CACD,OAAO,MAAM;GACZ,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;CACL;CAEA,IAAI,SAAS,2BAA2B;CAExC,IAAI,CAAC,QAAQ;EACX,SAAS,cAAc,YAAY,QAAQ,CAAC,CAAC,cAAc;GACzD,OAAO,2BAA2B;EACpC,CAAC;EACD,2BAA2B,UAAU;CACvC;CAEA,MAAM,iBAAiB,MAAM;CAE7B,IAAI,EAAE,eAAe,iBACnB,MAAM,IAAI,YACR,uDACF;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"waitForTransactionStatus.js","names":[],"sources":["../../../../../src/core/tasks/helpers/waitForTransactionStatus.ts"],"sourcesContent":["import type { FullStatusData, LiFiStep, StatusResponse } from '@lifi/types'\nimport { getStatus } from '../../../actions/getStatus.js'\nimport { ServerError } from '../../../errors/errors.js'\nimport type { ExecutionActionType, SDKClient } from '../../../types/core.js'\nimport { waitForResult } from '../../../utils/waitForResult.js'\nimport { getSubstatusMessage } from '../../actionMessages.js'\nimport type { StatusManager } from '../../StatusManager.js'\n\nconst TRANSACTION_HASH_OBSERVERS: Record<string, Promise<StatusResponse>> = {}\n\nexport async function waitForTransactionStatus(\n client: SDKClient,\n statusManager: StatusManager,\n txHash: string,\n step: LiFiStep,\n actionType: ExecutionActionType,\n interval = 5_000\n): Promise<StatusResponse> {\n const _getStatus = (): Promise<StatusResponse | undefined> => {\n return getStatus(client, {\n fromChain: step.action.fromChainId,\n fromAddress: step.action.fromAddress,\n toChain: step.action.toChainId,\n txHash,\n ...(step.tool !== 'custom' && { bridge: step.tool }),\n ...(step.transactionId && { transactionId: step.transactionId }),\n })\n .then((statusResponse) => {\n switch (statusResponse.status) {\n case 'DONE':\n return statusResponse\n case 'PENDING': {\n const pendingStatus = statusResponse as FullStatusData\n statusManager?.updateAction(step, actionType, 'PENDING', {\n substatus: statusResponse.substatus,\n substatusMessage:\n statusResponse.substatusMessage ||\n getSubstatusMessage(\n statusResponse.status,\n statusResponse.substatus\n ),\n // Most bridges implement no `getExplorerLink`, so fall back to\n // the LI.FI explorer rather than leave the user with no link.\n txLink:\n pendingStatus.bridgeExplorerLink ??\n pendingStatus.lifiExplorerLink,\n })\n return undefined\n }\n case 'NOT_FOUND':\n return undefined\n default:\n return Promise.reject()\n }\n })\n .catch((e) => {\n if (process.env.NODE_ENV === 'development') {\n console.debug('Fetching status from backend failed.', e)\n }\n return undefined\n })\n }\n\n let status = TRANSACTION_HASH_OBSERVERS[txHash]\n\n if (!status) {\n status = waitForResult(_getStatus, interval).finally(() => {\n delete TRANSACTION_HASH_OBSERVERS[txHash]\n })\n TRANSACTION_HASH_OBSERVERS[txHash] = status\n }\n\n const resolvedStatus = await status\n\n if (!('receiving' in resolvedStatus)) {\n throw new ServerError(\n \"Status doesn't contain destination chain information.\"\n )\n }\n\n return resolvedStatus\n}\n"],"mappings":";;;;;AAQA,MAAM,6BAAsE,CAAC;AAE7E,eAAsB,yBACpB,QACA,eACA,QACA,MACA,YACA,WAAW,KACc;CACzB,MAAM,mBAAwD;EAC5D,OAAO,UAAU,QAAQ;GACvB,WAAW,KAAK,OAAO;GACvB,aAAa,KAAK,OAAO;GACzB,SAAS,KAAK,OAAO;GACrB;GACA,GAAI,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,KAAK;GAClD,GAAI,KAAK,iBAAiB,EAAE,eAAe,KAAK,cAAc;EAChE,CAAC,CAAC,CACC,MAAM,mBAAmB;GACxB,QAAQ,eAAe,QAAvB;IACE,KAAK,QACH,OAAO;IACT,KAAK,WAAW;KACd,MAAM,gBAAgB;KACtB,eAAe,aAAa,MAAM,YAAY,WAAW;MACvD,WAAW,eAAe;MAC1B,kBACE,eAAe,oBACf,oBACE,eAAe,QACf,eAAe,SACjB;MAGF,QACE,cAAc,sBACd,cAAc;KAClB,CAAC;KACD;IACF;IACA,KAAK,aACH;IACF,SACE,OAAO,QAAQ,OAAO;GAC1B;EACF,CAAC,CAAC,CACD,OAAO,MAAM;GACZ,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;CACL;CAEA,IAAI,SAAS,2BAA2B;CAExC,IAAI,CAAC,QAAQ;EACX,SAAS,cAAc,YAAY,QAAQ,CAAC,CAAC,cAAc;GACzD,OAAO,2BAA2B;EACpC,CAAC;EACD,2BAA2B,UAAU;CACvC;CAEA,MAAM,iBAAiB,MAAM;CAE7B,IAAI,EAAE,eAAe,iBACnB,MAAM,IAAI,YACR,uDACF;CAGF,OAAO;AACT"}
@@ -51,5 +51,6 @@ import { sleep } from "./utils/sleep.js";
51
51
  import { waitForResult } from "./utils/waitForResult.js";
52
52
  import { LruMap, withDedupe } from "./utils/withDedupe.js";
53
53
  import { withTimeout } from "./utils/withTimeout.js";
54
+ import { name, version } from "./version.js";
54
55
  export * from "@lifi/types";
55
- export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
56
+ export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
package/dist/esm/index.js CHANGED
@@ -2,6 +2,7 @@ import { BaseError } from "./errors/baseError.js";
2
2
  import { ErrorMessage, ErrorName, LiFiErrorCode } from "./errors/constants.js";
3
3
  import { BalanceError, ExecuteStepRetryError, ProviderError, RPCError, ServerError, TransactionError, UnknownError, ValidationError } from "./errors/errors.js";
4
4
  import { HTTPError } from "./errors/httpError.js";
5
+ import { name, version } from "./version.js";
5
6
  import { SDKError } from "./errors/SDKError.js";
6
7
  import { sleep } from "./utils/sleep.js";
7
8
  import { LruMap, withDedupe } from "./utils/withDedupe.js";
@@ -49,4 +50,4 @@ import { fetchTxErrorDetails } from "./utils/fetchTxErrorDetails.js";
49
50
  import { isHex } from "./utils/isHex.js";
50
51
  import { parseUnits } from "./utils/parseUnits.js";
51
52
  export * from "@lifi/types";
52
- export { BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CheckBalanceTask, ErrorMessage, ErrorName, ExecuteStepRetryError, HTTPError, InMemoryStorage, LiFiErrorCode, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, RPCError, SDKError, ServerError, StatusManager, TaskPipeline, TransactionError, UnknownError, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
53
+ export { BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CheckBalanceTask, ErrorMessage, ErrorName, ExecuteStepRetryError, HTTPError, InMemoryStorage, LiFiErrorCode, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, RPCError, SDKError, ServerError, StatusManager, TaskPipeline, TransactionError, UnknownError, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
@@ -4,7 +4,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
4
4
  try {
5
5
  const pkgName = packageName ?? "@lifi/sdk";
6
6
  const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
7
- const currentVersion = packageVersion ?? "0.0.0-preview-c7217047";
7
+ const currentVersion = packageVersion ?? "0.0.0-preview-479fb196";
8
8
  if (latestVersion > currentVersion) console.warn(`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
9
9
  } catch (_error) {}
10
10
  };
@@ -1,5 +1,5 @@
1
1
  //#region src/version.d.ts
2
2
  export declare const name = "@lifi/sdk";
3
- export declare const version = "0.0.0-preview-c7217047";
3
+ export declare const version = "0.0.0-preview-479fb196";
4
4
  //#endregion
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  const name = "@lifi/sdk";
3
- const version = "0.0.0-preview-c7217047";
3
+ const version = "0.0.0-preview-479fb196";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '0.0.0-preview-c7217047'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '0.0.0-preview-479fb196'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "0.0.0-preview-c7217047",
3
+ "version": "0.0.0-preview-479fb196",
4
4
  "description": "LI.FI SDK for Any-to-Any Cross-Chain-Swap",
5
5
  "homepage": "https://github.com/lifinance/sdk",
6
6
  "bugs": {
@@ -28,7 +28,7 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
- "@lifi/types": "^18.6.0"
31
+ "@lifi/types": "^18.10.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
@@ -87,7 +87,18 @@ export function createClient(options: SDKConfig): SDKClient {
87
87
  ) => TClient & TExtensions {
88
88
  return (extendFn) => {
89
89
  const extensions = extendFn(base)
90
- const extended = { ...base, ...extensions } as TClient & typeof extensions
90
+ // Copy descriptors rather than spreading. `config` and `providers` are
91
+ // accessors over closure variables, and `setProviders` reassigns
92
+ // `_providers` — so a spread would freeze the extension on the values
93
+ // those getters happened to return at extend time, leaving it with a
94
+ // provider list that never updates.
95
+ const extended = Object.defineProperties(
96
+ {},
97
+ {
98
+ ...Object.getOwnPropertyDescriptors(base),
99
+ ...Object.getOwnPropertyDescriptors(extensions),
100
+ }
101
+ ) as TClient & typeof extensions
91
102
 
92
103
  // Preserve the extend function for further extensions
93
104
  return Object.assign(extended, {
@@ -29,7 +29,8 @@ export async function waitForTransactionStatus(
29
29
  switch (statusResponse.status) {
30
30
  case 'DONE':
31
31
  return statusResponse
32
- case 'PENDING':
32
+ case 'PENDING': {
33
+ const pendingStatus = statusResponse as FullStatusData
33
34
  statusManager?.updateAction(step, actionType, 'PENDING', {
34
35
  substatus: statusResponse.substatus,
35
36
  substatusMessage:
@@ -38,9 +39,14 @@ export async function waitForTransactionStatus(
38
39
  statusResponse.status,
39
40
  statusResponse.substatus
40
41
  ),
41
- txLink: (statusResponse as FullStatusData).bridgeExplorerLink,
42
+ // Most bridges implement no `getExplorerLink`, so fall back to
43
+ // the LI.FI explorer rather than leave the user with no link.
44
+ txLink:
45
+ pendingStatus.bridgeExplorerLink ??
46
+ pendingStatus.lifiExplorerLink,
42
47
  })
43
48
  return undefined
49
+ }
44
50
  case 'NOT_FOUND':
45
51
  return undefined
46
52
  default:
package/src/index.ts CHANGED
@@ -126,3 +126,4 @@ export { sleep } from './utils/sleep.js'
126
126
  export { waitForResult } from './utils/waitForResult.js'
127
127
  export { LruMap, withDedupe } from './utils/withDedupe.js'
128
128
  export { withTimeout } from './utils/withTimeout.js'
129
+ export { name, version } from './version.js'
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk'
2
- export const version = '0.0.0-preview-c7217047'
2
+ export const version = '0.0.0-preview-479fb196'