@lifi/sdk 3.0.0-alpha.33 → 3.0.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/package.json +2 -2
  2. package/src/_cjs/config.js +41 -21
  3. package/src/_cjs/config.js.map +1 -1
  4. package/src/_cjs/core/EVM/EVM.js +0 -3
  5. package/src/_cjs/core/EVM/EVM.js.map +1 -1
  6. package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
  7. package/src/_cjs/core/EVM/types.js.map +1 -1
  8. package/src/_cjs/core/EVM/utils.js +2 -5
  9. package/src/_cjs/core/EVM/utils.js.map +1 -1
  10. package/src/_cjs/createConfig.js +10 -25
  11. package/src/_cjs/createConfig.js.map +1 -1
  12. package/src/_cjs/services/api.js +18 -11
  13. package/src/_cjs/services/api.js.map +1 -1
  14. package/src/_cjs/version.js +1 -1
  15. package/src/_esm/config.js +40 -20
  16. package/src/_esm/config.js.map +1 -1
  17. package/src/_esm/core/EVM/EVM.js +0 -3
  18. package/src/_esm/core/EVM/EVM.js.map +1 -1
  19. package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
  20. package/src/_esm/core/EVM/types.js.map +1 -1
  21. package/src/_esm/core/EVM/utils.js +3 -5
  22. package/src/_esm/core/EVM/utils.js.map +1 -1
  23. package/src/_esm/createConfig.js +11 -27
  24. package/src/_esm/createConfig.js.map +1 -1
  25. package/src/_esm/services/api.js +19 -11
  26. package/src/_esm/services/api.js.map +1 -1
  27. package/src/_esm/version.js +1 -1
  28. package/src/_types/config.d.ts +5 -3
  29. package/src/_types/config.d.ts.map +1 -1
  30. package/src/_types/core/EVM/EVM.d.ts.map +1 -1
  31. package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
  32. package/src/_types/core/EVM/types.d.ts +1 -3
  33. package/src/_types/core/EVM/types.d.ts.map +1 -1
  34. package/src/_types/core/EVM/utils.d.ts.map +1 -1
  35. package/src/_types/createConfig.d.ts +1 -10
  36. package/src/_types/createConfig.d.ts.map +1 -1
  37. package/src/_types/services/api.d.ts +4 -3
  38. package/src/_types/services/api.d.ts.map +1 -1
  39. package/src/_types/types/internal.d.ts +8 -6
  40. package/src/_types/types/internal.d.ts.map +1 -1
  41. package/src/_types/version.d.ts +1 -1
  42. package/src/config.ts +40 -20
  43. package/src/core/EVM/EVM.ts +0 -3
  44. package/src/core/EVM/EVMStepExecutor.ts +4 -2
  45. package/src/core/EVM/types.ts +1 -3
  46. package/src/core/EVM/utils.ts +3 -8
  47. package/src/createConfig.ts +10 -30
  48. package/src/services/api.ts +27 -23
  49. package/src/types/internal.ts +8 -6
  50. package/src/version.ts +1 -1
@@ -21,8 +21,8 @@ import type {
21
21
  TokensResponse,
22
22
  ToolsRequest,
23
23
  ToolsResponse,
24
- WalletAnalytics,
25
- WalletAnalyticsRequest,
24
+ TransactionAnalyticsRequest,
25
+ TransactionAnalyticsResponse,
26
26
  } from '@lifi/types'
27
27
  import { config } from '../config.js'
28
28
  import { request } from '../request.js'
@@ -267,6 +267,7 @@ export const getRoutes = async (
267
267
  const _config = config.get()
268
268
  // apply defaults
269
269
  params.options = {
270
+ integrator: _config.integrator,
270
271
  ..._config.routeOptions,
271
272
  ...params.options,
272
273
  }
@@ -424,10 +425,12 @@ export const getGasRecommendation = async (
424
425
  /**
425
426
  * Get all the available connections for swap/bridging tokens
426
427
  * @param connectionRequest ConnectionsRequest
428
+ * @param options - Request options
427
429
  * @returns ConnectionsResponse
428
430
  */
429
431
  export const getConnections = async (
430
- connectionRequest: ConnectionsRequest
432
+ connectionRequest: ConnectionsRequest,
433
+ options?: RequestOptions
431
434
  ): Promise<ConnectionsResponse> => {
432
435
  const url = new URL(`${config.get().apiUrl}/connections`)
433
436
 
@@ -465,7 +468,7 @@ export const getConnections = async (
465
468
  }
466
469
  })
467
470
  try {
468
- const response = await request<ConnectionsResponse>(url.toString())
471
+ const response = await request<ConnectionsResponse>(url, options)
469
472
  return response
470
473
  } catch (e) {
471
474
  throw await parseBackendError(e)
@@ -473,33 +476,34 @@ export const getConnections = async (
473
476
  }
474
477
 
475
478
  export const getTransactionHistory = async (
476
- walletAnalyticsRequest: WalletAnalyticsRequest
477
- ): Promise<WalletAnalytics> => {
479
+ { wallet, status, fromTimestamp, toTimestamp }: TransactionAnalyticsRequest,
480
+ options?: RequestOptions
481
+ ): Promise<TransactionAnalyticsResponse> => {
482
+ if (!wallet) {
483
+ throw new ValidationError('Required parameter "wallet" is missing.')
484
+ }
485
+
478
486
  const _config = config.get()
479
487
 
480
- if (!walletAnalyticsRequest.fromTimestamp) {
481
- throw new ValidationError('Required parameter "fromTimestamp" is missing.')
482
- }
488
+ const url = new URL(`${_config.apiUrl}/analytics/transfers`)
483
489
 
484
- if (!walletAnalyticsRequest.toTimestamp) {
485
- throw new ValidationError('Required parameter "toTimestamp" is missing.')
490
+ url.searchParams.append('integrator', _config.integrator)
491
+ url.searchParams.append('wallet', wallet)
492
+
493
+ if (status) {
494
+ url.searchParams.append('status', status)
486
495
  }
487
496
 
488
- const url = new URL(
489
- `${_config.apiUrl}/analytics/wallets/${walletAnalyticsRequest.walletAddress}`
490
- )
497
+ if (fromTimestamp) {
498
+ url.searchParams.append('fromTimestamp', fromTimestamp.toString())
499
+ }
491
500
 
492
- url.searchParams.append(
493
- 'fromTimestamp',
494
- walletAnalyticsRequest.fromTimestamp.toString()
495
- )
501
+ if (toTimestamp) {
502
+ url.searchParams.append('toTimestamp', toTimestamp.toString())
503
+ }
496
504
 
497
- url.searchParams.append(
498
- 'toTimestamp',
499
- walletAnalyticsRequest.toTimestamp.toString()
500
- )
501
505
  try {
502
- const response = await request<WalletAnalytics>(url)
506
+ const response = await request<TransactionAnalyticsResponse>(url, options)
503
507
  return response
504
508
  } catch (e) {
505
509
  throw await parseBackendError(e)
@@ -1,16 +1,18 @@
1
- import type { ChainId, RouteOptions } from '@lifi/types'
1
+ import type { ChainId, ExtendedChain, RouteOptions } from '@lifi/types'
2
2
  import type { SDKProvider } from '../core/types.js'
3
3
 
4
4
  export interface SDKConfig {
5
- integrator: string
6
- apiUrl: string
7
5
  apiKey?: string
6
+ apiUrl: string
7
+ integrator: string
8
8
  userId?: string
9
- disableVersionCheck?: boolean
10
- widgetVersion?: string
11
- routeOptions?: RouteOptions
12
9
  providers?: SDKProvider[]
10
+ routeOptions?: RouteOptions
13
11
  rpcUrls: Partial<Record<ChainId, string[]>>
12
+ chains: ExtendedChain[]
13
+ disableVersionCheck?: boolean
14
+ widgetVersion?: string
15
+ preloadChains: boolean
14
16
  }
15
17
 
16
18
  export interface SDKOptions extends Partial<Omit<SDKConfig, 'integrator'>> {
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk'
2
- export const version = '3.0.0-alpha.33'
2
+ export const version = '3.0.0-alpha.35'