@lifi/sdk 3.0.0-alpha.4 → 3.0.0-alpha.7

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 (115) hide show
  1. package/dist/LiFi.d.ts +28 -21
  2. package/dist/LiFi.js +20 -13
  3. package/dist/allowance/setAllowance.d.ts +2 -1
  4. package/dist/allowance/setAllowance.js +23 -7
  5. package/dist/cjs/LiFi.d.ts +28 -21
  6. package/dist/cjs/LiFi.js +20 -13
  7. package/dist/cjs/allowance/setAllowance.d.ts +2 -1
  8. package/dist/cjs/allowance/setAllowance.js +23 -7
  9. package/dist/cjs/connectors.d.ts +1 -1
  10. package/dist/cjs/execution/BaseStepExecutor.d.ts +12 -0
  11. package/dist/cjs/execution/BaseStepExecutor.js +27 -0
  12. package/dist/cjs/execution/EVMStepExecutor.d.ts +13 -0
  13. package/dist/cjs/execution/EVMStepExecutor.js +292 -0
  14. package/dist/cjs/execution/RouteExecutionManager.d.ts +6 -7
  15. package/dist/cjs/execution/RouteExecutionManager.js +19 -19
  16. package/dist/cjs/execution/StatusManager.d.ts +8 -7
  17. package/dist/cjs/execution/StatusManager.js +1 -1
  18. package/dist/cjs/execution/StepExecutionManager.d.ts +3 -3
  19. package/dist/cjs/execution/StepExecutionManager.js +34 -29
  20. package/dist/cjs/execution/checkAllowance.d.ts +3 -2
  21. package/dist/cjs/execution/checkAllowance.js +1 -1
  22. package/dist/cjs/execution/checkBalance.d.ts +2 -2
  23. package/dist/cjs/execution/index.d.ts +1 -0
  24. package/dist/cjs/execution/index.js +1 -0
  25. package/dist/cjs/execution/multisig.d.ts +2 -2
  26. package/dist/cjs/execution/prepareRestart.d.ts +2 -3
  27. package/dist/cjs/execution/prepareRestart.js +2 -2
  28. package/dist/cjs/execution/stepComparison.d.ts +4 -3
  29. package/dist/cjs/execution/stepComparison.js +1 -1
  30. package/dist/cjs/execution/switchChain.d.ts +4 -3
  31. package/dist/cjs/execution/switchChain.js +1 -0
  32. package/dist/cjs/{types/internal.types.d.ts → execution/types.d.ts} +36 -96
  33. package/dist/cjs/execution/utils.d.ts +2 -2
  34. package/dist/cjs/execution/waitForReceivingTransaction.d.ts +3 -3
  35. package/dist/cjs/helpers.d.ts +2 -2
  36. package/dist/cjs/index.d.ts +3 -1
  37. package/dist/cjs/index.js +6 -3
  38. package/dist/cjs/providers/BaseProvider.d.ts +7 -0
  39. package/dist/cjs/providers/BaseProvider.js +6 -0
  40. package/dist/cjs/providers/EVMProvider.d.ts +16 -0
  41. package/dist/cjs/providers/EVMProvider.js +28 -0
  42. package/dist/cjs/providers/SolanaProvider.d.ts +15 -0
  43. package/dist/cjs/providers/SolanaProvider.js +32 -0
  44. package/dist/cjs/providers/types.d.ts +0 -0
  45. package/dist/cjs/providers/types.js +1 -0
  46. package/dist/cjs/request.js +11 -5
  47. package/dist/cjs/services/ApiService.d.ts +4 -5
  48. package/dist/cjs/services/ApiService.js +2 -2
  49. package/dist/cjs/services/ConfigService.d.ts +6 -5
  50. package/dist/cjs/services/ConfigService.js +3 -3
  51. package/dist/cjs/typeguards.d.ts +2 -2
  52. package/dist/cjs/types/index.d.ts +1 -3
  53. package/dist/cjs/types/index.js +1 -5
  54. package/dist/cjs/types/internal.d.ts +60 -0
  55. package/dist/cjs/types/internal.js +2 -0
  56. package/dist/cjs/utils/parseError.d.ts +4 -4
  57. package/dist/cjs/version.d.ts +1 -1
  58. package/dist/cjs/version.js +1 -1
  59. package/dist/connectors.d.ts +1 -1
  60. package/dist/execution/BaseStepExecutor.d.ts +12 -0
  61. package/dist/execution/BaseStepExecutor.js +23 -0
  62. package/dist/execution/EVMStepExecutor.d.ts +13 -0
  63. package/dist/execution/EVMStepExecutor.js +285 -0
  64. package/dist/execution/RouteExecutionManager.d.ts +6 -7
  65. package/dist/execution/RouteExecutionManager.js +19 -19
  66. package/dist/execution/StatusManager.d.ts +8 -7
  67. package/dist/execution/StatusManager.js +1 -1
  68. package/dist/execution/StepExecutionManager.d.ts +3 -3
  69. package/dist/execution/StepExecutionManager.js +34 -29
  70. package/dist/execution/checkAllowance.d.ts +3 -2
  71. package/dist/execution/checkAllowance.js +1 -1
  72. package/dist/execution/checkBalance.d.ts +2 -2
  73. package/dist/execution/index.d.ts +1 -0
  74. package/dist/execution/index.js +1 -0
  75. package/dist/execution/multisig.d.ts +2 -2
  76. package/dist/execution/prepareRestart.d.ts +2 -3
  77. package/dist/execution/prepareRestart.js +2 -2
  78. package/dist/execution/stepComparison.d.ts +4 -3
  79. package/dist/execution/stepComparison.js +1 -1
  80. package/dist/execution/switchChain.d.ts +4 -3
  81. package/dist/execution/switchChain.js +1 -0
  82. package/dist/{types/internal.types.d.ts → execution/types.d.ts} +36 -96
  83. package/dist/execution/utils.d.ts +2 -2
  84. package/dist/execution/waitForReceivingTransaction.d.ts +3 -3
  85. package/dist/helpers.d.ts +2 -2
  86. package/dist/index.d.ts +3 -1
  87. package/dist/index.js +3 -1
  88. package/dist/providers/BaseProvider.d.ts +7 -0
  89. package/dist/providers/BaseProvider.js +2 -0
  90. package/dist/providers/EVMProvider.d.ts +16 -0
  91. package/dist/providers/EVMProvider.js +24 -0
  92. package/dist/providers/SolanaProvider.d.ts +15 -0
  93. package/dist/providers/SolanaProvider.js +28 -0
  94. package/dist/providers/types.d.ts +0 -0
  95. package/dist/providers/types.js +1 -0
  96. package/dist/request.js +11 -5
  97. package/dist/services/ApiService.d.ts +4 -5
  98. package/dist/services/ApiService.js +2 -2
  99. package/dist/services/ConfigService.d.ts +6 -5
  100. package/dist/services/ConfigService.js +3 -3
  101. package/dist/typeguards.d.ts +2 -2
  102. package/dist/types/index.d.ts +1 -3
  103. package/dist/types/index.js +1 -3
  104. package/dist/types/internal.d.ts +60 -0
  105. package/dist/types/internal.js +1 -0
  106. package/dist/utils/parseError.d.ts +4 -4
  107. package/dist/version.d.ts +1 -1
  108. package/dist/version.js +1 -1
  109. package/package.json +61 -62
  110. package/dist/cjs/execution/StepExecutor.d.ts +0 -15
  111. package/dist/cjs/execution/StepExecutor.js +0 -62
  112. package/dist/execution/StepExecutor.d.ts +0 -15
  113. package/dist/execution/StepExecutor.js +0 -58
  114. /package/dist/cjs/{types/internal.types.js → execution/types.js} +0 -0
  115. /package/dist/{types/internal.types.js → execution/types.js} +0 -0
@@ -0,0 +1,16 @@
1
+ import type { LiFiStep } from '@lifi/types';
2
+ import { type WalletClient } from 'viem';
3
+ import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
4
+ import type { StepExecutorOptions } from '../execution/types';
5
+ import { BaseProvider } from './BaseProvider';
6
+ export type GetEVMWalletClient = () => Promise<WalletClient>;
7
+ export interface EVMProviderOptions {
8
+ getWalletClient: GetEVMWalletClient;
9
+ }
10
+ export declare class EVMProvider extends BaseProvider {
11
+ getWalletClient?: GetEVMWalletClient;
12
+ constructor(options?: EVMProviderOptions);
13
+ isProviderStep(step: LiFiStep): boolean;
14
+ getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
15
+ setOptions(options: EVMProviderOptions): void;
16
+ }
@@ -0,0 +1,24 @@
1
+ import { isAddress } from 'viem';
2
+ import { EVMStepExecutor } from '../execution/EVMStepExecutor';
3
+ import { BaseProvider } from './BaseProvider';
4
+ export class EVMProvider extends BaseProvider {
5
+ constructor(options) {
6
+ super();
7
+ this.getWalletClient = options?.getWalletClient;
8
+ }
9
+ isProviderStep(step) {
10
+ const isProviderStep = isAddress(step.action.fromAddress);
11
+ return isProviderStep;
12
+ }
13
+ async getStepExecutor(options) {
14
+ if (!this.getWalletClient) {
15
+ throw new Error(`getWalletClient is not provided.`);
16
+ }
17
+ const walletClient = await this.getWalletClient();
18
+ const executor = new EVMStepExecutor({ walletClient, ...options });
19
+ return executor;
20
+ }
21
+ setOptions(options) {
22
+ this.getWalletClient = options.getWalletClient;
23
+ }
24
+ }
@@ -0,0 +1,15 @@
1
+ import type { LiFiStep } from '@lifi/types';
2
+ import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
3
+ import type { StepExecutorOptions } from '../execution/types';
4
+ import { BaseProvider } from './BaseProvider';
5
+ export type GetSolanaWalletClient = () => Promise<unknown>;
6
+ export interface SolanaProviderOptions {
7
+ getWalletClient: GetSolanaWalletClient;
8
+ }
9
+ export declare class SolanaProvider extends BaseProvider {
10
+ getWalletClient?: GetSolanaWalletClient;
11
+ constructor(options?: SolanaProviderOptions);
12
+ isProviderStep(step: LiFiStep): boolean;
13
+ getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
14
+ setOptions(options: SolanaProviderOptions): void;
15
+ }
@@ -0,0 +1,28 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import { BaseProvider } from './BaseProvider';
3
+ export class SolanaProvider extends BaseProvider {
4
+ constructor(options) {
5
+ super();
6
+ this.getWalletClient = options?.getWalletClient;
7
+ }
8
+ isProviderStep(step) {
9
+ try {
10
+ const publickKey = new PublicKey(step.action.fromAddress);
11
+ const isProviderStep = PublicKey.isOnCurve(publickKey);
12
+ return isProviderStep;
13
+ }
14
+ catch (error) {
15
+ return false;
16
+ }
17
+ }
18
+ async getStepExecutor(options) {
19
+ if (!this.getWalletClient) {
20
+ throw new Error(`getWalletClient is not provided.`);
21
+ }
22
+ const walletClient = await this.getWalletClient();
23
+ return null;
24
+ }
25
+ setOptions(options) {
26
+ this.getWalletClient = options.getWalletClient;
27
+ }
28
+ }
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
package/dist/request.js CHANGED
@@ -8,32 +8,38 @@ export const requestSettings = {
8
8
  export const request = async (url, options = {
9
9
  retries: requestSettings.retries,
10
10
  }) => {
11
- const { userId, integrator, widgetVersion } = ConfigService.getInstance().getConfig();
11
+ const { userId, integrator, widgetVersion, apiKey } = ConfigService.getInstance().getConfig();
12
12
  options.retries = options.retries ?? requestSettings.retries;
13
13
  try {
14
14
  if (!options.skipTrackingHeaders) {
15
+ if (apiKey) {
16
+ options.headers = {
17
+ ...options?.headers,
18
+ 'x-lifi-api-key': apiKey,
19
+ };
20
+ }
15
21
  if (userId) {
16
22
  options.headers = {
17
23
  ...options?.headers,
18
- 'X-LIFI-UserId': userId,
24
+ 'x-lifi-userid': userId,
19
25
  };
20
26
  }
21
27
  if (widgetVersion) {
22
28
  options.headers = {
23
29
  ...options?.headers,
24
- 'X-LIFI-Widget': widgetVersion,
30
+ 'x-lifi-widget': widgetVersion,
25
31
  };
26
32
  }
27
33
  if (version) {
28
34
  options.headers = {
29
35
  ...options?.headers,
30
- 'X-LIFI-SDK': version,
36
+ 'x-lifi-sdk': version,
31
37
  };
32
38
  }
33
39
  // integrator is mandatory during SDK initialization
34
40
  options.headers = {
35
41
  ...options?.headers,
36
- 'X-LIFI-Integrator': integrator,
42
+ 'x-lifi-integrator': integrator,
37
43
  };
38
44
  }
39
45
  const response = await fetch(url, options);
@@ -1,14 +1,13 @@
1
- import type { ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, QuoteRequest, RequestOptions, TokensRequest, TokensResponse } from '@lifi/types';
2
- import type { ChainId, ChainKey, ExtendedChain, PossibilitiesRequest, PossibilitiesResponse, RoutesRequest, RoutesResponse, StatusResponse, Token, ToolsRequest, ToolsResponse } from '../types';
1
+ import type { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LiFiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
3
2
  declare const _default: {
4
3
  getChains: (options?: RequestOptions | undefined) => Promise<ExtendedChain[]>;
5
- getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
4
+ getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<LiFiStep>;
6
5
  getGasRecommendation: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
7
6
  getPossibilities: (requestConfig?: PossibilitiesRequest | undefined, options?: RequestOptions | undefined) => Promise<PossibilitiesResponse>;
8
- getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
7
+ getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<LiFiStep>;
9
8
  getRoutes: (requestConfig: RoutesRequest, options?: RequestOptions | undefined) => Promise<RoutesResponse>;
10
9
  getStatus: (requestConfig: GetStatusRequest, options?: RequestOptions | undefined) => Promise<StatusResponse>;
11
- getStepTransaction: (step: LifiStep, options?: RequestOptions | undefined) => Promise<LifiStep>;
10
+ getStepTransaction: (step: LiFiStep, options?: RequestOptions | undefined) => Promise<LiFiStep>;
12
11
  getToken: (chain: ChainId | ChainKey, token: string, options?: RequestOptions | undefined) => Promise<Token>;
13
12
  getTokens: (requestConfig?: TokensRequest | undefined, options?: RequestOptions | undefined) => Promise<TokensResponse>;
14
13
  getTools: (requestConfig?: ToolsRequest | undefined, options?: RequestOptions | undefined) => Promise<ToolsResponse>;
@@ -276,10 +276,10 @@ const getAvailableConnections = async (connectionRequest) => {
276
276
  url.searchParams.append('fromToken', fromToken);
277
277
  }
278
278
  if (toChain) {
279
- url.searchParams.append('fromToken', toChain);
279
+ url.searchParams.append('toChain', toChain);
280
280
  }
281
281
  if (toToken) {
282
- url.searchParams.append('fromToken', toToken);
282
+ url.searchParams.append('toToken', toToken);
283
283
  }
284
284
  const connectionRequestArrayParams = [
285
285
  'allowBridges',
@@ -1,4 +1,5 @@
1
- import type { Chain, Config, ConfigUpdate } from '../types';
1
+ import type { Chain } from '@lifi/types';
2
+ import type { SDKConfig, SDKOptions } from '../types';
2
3
  export default class ConfigService {
3
4
  private static instance;
4
5
  private readonly config;
@@ -12,12 +13,12 @@ export default class ConfigService {
12
13
  * This call immediately returns the current config. It does not make sure that all chain data is already loaded
13
14
  * Use this if you need access to basic information like API urls or settings
14
15
  */
15
- getConfig: () => Config;
16
+ getConfig: () => SDKConfig;
16
17
  /**
17
18
  * This call waits for all setup promises to be done.
18
19
  * Use this if you need access to chain data (RPCs or multicalls)
19
20
  */
20
- getConfigAsync: () => Promise<Config>;
21
- updateConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
22
- updateChains: (chains: Chain[]) => Config;
21
+ getConfigAsync: () => Promise<SDKConfig>;
22
+ updateConfig: (configUpdate: Partial<SDKOptions>) => SDKConfig;
23
+ updateChains: (chains: Chain[]) => SDKConfig;
23
24
  }
@@ -1,6 +1,5 @@
1
- import { ChainId } from '../types';
1
+ import { ChainId } from '@lifi/types';
2
2
  const DefaultExecutionSettings = {
3
- /* eslint-disable-next-line @typescript-eslint/no-empty-function */
4
3
  updateRouteHook: () => { },
5
4
  switchChainHook: () => Promise.resolve(undefined),
6
5
  acceptExchangeRateUpdateHook: () => Promise.resolve(undefined),
@@ -36,6 +35,7 @@ class ConfigService {
36
35
  this.config.defaultExecutionSettings = Object.assign(this.config.defaultExecutionSettings, configUpdate.defaultExecutionSettings);
37
36
  // OPTIONS
38
37
  this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
38
+ this.config.apiKey = configUpdate.apiKey || this.config.apiKey;
39
39
  this.config.userId = configUpdate.userId || this.config.userId;
40
40
  this.config.integrator = configUpdate.integrator || this.config.integrator;
41
41
  this.config.defaultRouteOptions.integrator =
@@ -44,7 +44,7 @@ class ConfigService {
44
44
  this.config.integrator;
45
45
  this.config.widgetVersion =
46
46
  configUpdate.widgetVersion || this.config.widgetVersion;
47
- this.config.multisig = configUpdate.multisigConfig || this.config.multisig;
47
+ this.config.multisig = configUpdate.multisig || this.config.multisig;
48
48
  return this.config;
49
49
  };
50
50
  this.updateChains = (chains) => {
@@ -1,4 +1,4 @@
1
- import type { LifiStep, RoutesRequest, StaticToken } from './types';
1
+ import type { LiFiStep, RoutesRequest, StaticToken } from '@lifi/types';
2
2
  export declare const isRoutesRequest: (routesRequest: RoutesRequest) => routesRequest is RoutesRequest;
3
- export declare const isStep: (step: LifiStep) => step is LifiStep;
3
+ export declare const isStep: (step: LiFiStep) => step is LiFiStep;
4
4
  export declare const isToken: (token: StaticToken) => token is StaticToken;
@@ -1,4 +1,2 @@
1
- export * from '@lifi/types';
2
- export { ErrorCode, LiFiError } from '../utils/errors';
3
1
  export * from './abi';
4
- export * from './internal.types';
2
+ export * from './internal';
@@ -1,4 +1,2 @@
1
- export * from '@lifi/types';
2
- export { LiFiError } from '../utils/errors';
3
1
  export * from './abi';
4
- export * from './internal.types';
2
+ export * from './internal';
@@ -0,0 +1,60 @@
1
+ import type { ChainId, RouteOptions } from '@lifi/types';
2
+ import type { ExecutionSettings, InternalExecutionSettings, MultisigConfig } from '../execution/types';
3
+ import type { BaseProvider } from '../providers/BaseProvider';
4
+ export interface SDKConfig {
5
+ apiUrl: string;
6
+ apiKey?: string;
7
+ rpcs: Record<ChainId, string[]>;
8
+ multicallAddresses: Record<ChainId, string | undefined>;
9
+ defaultExecutionSettings: InternalExecutionSettings;
10
+ defaultRouteOptions: RouteOptions;
11
+ disableVersionCheck?: boolean;
12
+ userId?: string;
13
+ integrator: string;
14
+ widgetVersion?: string;
15
+ multisig?: MultisigConfig;
16
+ providers?: BaseProvider[];
17
+ }
18
+ export interface SDKOptions extends Partial<Omit<SDKConfig, 'defaultExecutionSettings' | 'integrator'>> {
19
+ defaultExecutionSettings?: ExecutionSettings;
20
+ integrator: string;
21
+ }
22
+ export interface TenderlyResponse {
23
+ hash: string;
24
+ block_hash: string;
25
+ block_number: number;
26
+ from: string;
27
+ gas: number;
28
+ gas_price: number;
29
+ gas_fee_cap: number;
30
+ gas_tip_cap: number;
31
+ cumulative_gas_used: number;
32
+ gas_used: number;
33
+ effective_gas_price: number;
34
+ input: string;
35
+ nonce: number;
36
+ to: string;
37
+ index: number;
38
+ value: string;
39
+ access_list: unknown;
40
+ status: boolean;
41
+ addresses: string[];
42
+ contract_ids: string[];
43
+ network_id: string;
44
+ timestamp: string;
45
+ function_selector: string;
46
+ l1_block_number: number;
47
+ l1_timestamp: number;
48
+ deposit_tx: boolean;
49
+ system_tx: boolean;
50
+ mint: number;
51
+ sig: {
52
+ v: string;
53
+ r: string;
54
+ s: string;
55
+ };
56
+ error_message: string;
57
+ method: string;
58
+ decoded_input: unknown;
59
+ call_trace: unknown;
60
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { LifiStep, Process } from '@lifi/types';
1
+ import type { LiFiStep, Process } from '@lifi/types';
2
2
  import { LiFiError } from './errors';
3
3
  /**
4
4
  * Available MetaMask error codes:
@@ -31,7 +31,7 @@ import { LiFiError } from './errors';
31
31
  * https://eips.ethereum.org/EIPS/eip-1474#error-codes
32
32
  * https://eips.ethereum.org/EIPS/eip-1193#provider-errors
33
33
  */
34
- export declare const getTransactionNotSentMessage: (step?: LifiStep, process?: Process) => Promise<string>;
35
- export declare const getTransactionFailedMessage: (step: LifiStep, txLink?: string) => Promise<string>;
36
- export declare const parseError: (e: any, step?: LifiStep, process?: Process) => Promise<LiFiError>;
34
+ export declare const getTransactionNotSentMessage: (step?: LiFiStep, process?: Process) => Promise<string>;
35
+ export declare const getTransactionFailedMessage: (step: LiFiStep, txLink?: string) => Promise<string>;
36
+ export declare const parseError: (e: any, step?: LiFiStep, process?: Process) => Promise<LiFiError>;
37
37
  export declare const parseBackendError: (e: any) => Promise<LiFiError>;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "3.0.0-alpha.4";
2
+ export declare const version = "3.0.0-alpha.7";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk';
2
- export const version = '3.0.0-alpha.4';
2
+ export const version = '3.0.0-alpha.7';
package/package.json CHANGED
@@ -1,23 +1,60 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.7",
4
4
  "description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
5
+ "keywords": [
6
+ "bridge",
7
+ "bridge-aggregation",
8
+ "cross-chain",
9
+ "cross-chain-applications",
10
+ "cross-chain-bridge",
11
+ "dapp",
12
+ "defi",
13
+ "ethereum",
14
+ "ethers",
15
+ "lifi",
16
+ "metamask",
17
+ "multi-chain",
18
+ "sdk",
19
+ "swap",
20
+ "viem",
21
+ "wagmi",
22
+ "web3",
23
+ "web3-react"
24
+ ],
25
+ "homepage": "https://github.com/lifinance/sdk",
26
+ "bugs": {
27
+ "url": "https://github.com/lifinance/sdk/issues"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+ssh://git@github.com/lifinance/sdk.git"
32
+ },
33
+ "license": "Apache-2.0",
34
+ "author": "Max Klenk <max@li.finance>",
5
35
  "main": "./dist/cjs/index.js",
6
36
  "module": "./dist/index.js",
7
37
  "types": "./dist/index.d.ts",
38
+ "directories": {
39
+ "test": "tests"
40
+ },
41
+ "files": [
42
+ "dist"
43
+ ],
8
44
  "scripts": {
9
45
  "addscope": "node tools/packagejson name @lifi/sdk",
10
46
  "build": "yarn clean && tsc --project ./tsconfig.json && tsc --project ./tsconfig.cjs.json",
11
47
  "clean": "node tools/cleanup",
12
48
  "coverage": "vitest run --coverage",
49
+ "_postinstall": "husky install",
13
50
  "lint": "eslint --ext .tsx --ext .ts ./src",
14
51
  "lint:fix": "eslint --ext .tsx --ext .ts ./src --fix",
52
+ "prepack": "pinst --disable",
53
+ "postpack": "pinst --enable",
15
54
  "package": "npm run build && npm pack",
16
- "postpublish": "npm run use:gitReadme && pinst --enable",
17
55
  "pre-commit": "lint-staged",
18
56
  "pre-push": "yarn types:check && yarn build && yarn test:unit",
19
- "prepare": "husky install",
20
- "prepublishOnly": "run-s build use:npmReadme && pinst --enable",
57
+ "prepublishOnly": "npm run build",
21
58
  "prettier:fix": "prettier --write ./src/.",
22
59
  "release": "standard-version -a",
23
60
  "release:alpha": "standard-version -a --prerelease alpha --skip.changelog",
@@ -27,87 +64,49 @@
27
64
  "test:e2e": "yarn test -c vitest.e2e.config.ts",
28
65
  "test:unit": "yarn test .unit.spec.ts",
29
66
  "types:check": "tsc --noEmit",
30
- "use:gitReadme": "mv 'README.md' 'npm.README.md' && mv 'git.README.md' 'README.md'",
31
- "use:npmReadme": "mv 'README.md' 'git.README.md' && mv 'npm.README.md' 'README.md'",
32
67
  "watch": "tsc -w -p ./tsconfig.json"
33
68
  },
34
- "standard-version": {
35
- "scripts": {
36
- "postbump": "node scripts/version.js && git add ."
37
- }
38
- },
39
69
  "lint-staged": {
40
70
  "src/**/*.{ts,tsx}": [
41
71
  "yarn run lint:fix",
42
72
  "yarn run prettier:fix"
43
73
  ]
44
74
  },
45
- "files": [
46
- "dist"
47
- ],
48
- "publishConfig": {
49
- "access": "public"
50
- },
51
- "author": "Max Klenk <max@li.finance>",
52
- "license": "Apache-2.0",
53
- "keywords": [
54
- "bridge",
55
- "bridge-aggregation",
56
- "cross-chain",
57
- "cross-chain-applications",
58
- "cross-chain-bridge",
59
- "dapp",
60
- "defi",
61
- "ethereum",
62
- "ethers",
63
- "lifi",
64
- "metamask",
65
- "multi-chain",
66
- "sdk",
67
- "swap",
68
- "viem",
69
- "wagmi",
70
- "web3",
71
- "web3-react"
72
- ],
73
- "homepage": "https://github.com/lifinance/sdk",
74
- "repository": {
75
- "type": "git",
76
- "url": "git+ssh://git@github.com/lifinance/sdk.git"
77
- },
78
- "bugs": {
79
- "url": "https://github.com/lifinance/sdk/issues"
80
- },
81
75
  "dependencies": {
82
- "@lifi/types": "^9.0.0-alpha.8",
76
+ "@lifi/types": "^9.0.0-alpha.12",
77
+ "@solana/web3.js": "^1.78.4",
83
78
  "eth-rpc-errors": "^4.0.3",
84
- "viem": "^1.6.0"
79
+ "viem": "^1.10.3"
85
80
  },
86
81
  "devDependencies": {
87
82
  "@commitlint/cli": "^17.7.1",
88
83
  "@commitlint/config-conventional": "^17.7.0",
89
84
  "@mswjs/interceptors": "^0.22.16",
90
85
  "@types/ws": "^8.5.5",
91
- "@typescript-eslint/eslint-plugin": "^6.3.0",
92
- "@typescript-eslint/parser": "^6.3.0",
93
- "@vitest/coverage-v8": "^0.34.1",
86
+ "@typescript-eslint/eslint-plugin": "^6.6.0",
87
+ "@typescript-eslint/parser": "^6.6.0",
88
+ "@vitest/coverage-v8": "^0.34.3",
94
89
  "cross-fetch": "^4.0.0",
95
- "eslint": "^8.47.0",
90
+ "eslint": "^8.48.0",
96
91
  "eslint-config-prettier": "^9.0.0",
97
- "eslint-plugin-jsdoc": "^46.4.6",
92
+ "eslint-plugin-jsdoc": "^46.5.1",
98
93
  "eslint-plugin-prettier": "^5.0.0",
99
94
  "husky": "^8.0.3",
100
- "lint-staged": "^14.0.0",
95
+ "lint-staged": "^14.0.1",
101
96
  "msw": "1.0.1",
102
- "npm-run-all": "^4.1.5",
103
97
  "pinst": "^3.0.0",
104
- "prettier": "^3.0.1",
98
+ "prettier": "^3.0.3",
105
99
  "standard-version": "^9.5.0",
106
- "typescript": "^5.1.6",
107
- "vitest": "^0.34.1"
100
+ "typescript": "^5.2.2",
101
+ "vitest": "^0.34.3"
108
102
  },
109
- "directories": {
110
- "test": "test"
103
+ "packageManager": "yarn@3.6.3",
104
+ "publishConfig": {
105
+ "access": "public"
111
106
  },
112
- "packageManager": "yarn@3.6.1"
107
+ "standard-version": {
108
+ "scripts": {
109
+ "postbump": "node scripts/version.js && git add ."
110
+ }
111
+ }
113
112
  }
@@ -1,15 +0,0 @@
1
- import type { WalletClient } from 'viem';
2
- import type { InteractionSettings, InternalExecutionSettings, LifiStep } from '../types';
3
- import type { StatusManager } from './StatusManager';
4
- import { StepExecutionManager } from './StepExecutionManager';
5
- export declare class StepExecutor {
6
- stepExecutionManager: StepExecutionManager;
7
- statusManager: StatusManager;
8
- settings: InternalExecutionSettings;
9
- allowUserInteraction: boolean;
10
- executionStopped: boolean;
11
- constructor(statusManager: StatusManager, settings: InternalExecutionSettings);
12
- setInteraction: (settings?: InteractionSettings) => void;
13
- checkChain: () => never;
14
- executeStep: (walletClient: WalletClient, step: LifiStep) => Promise<LifiStep>;
15
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StepExecutor = void 0;
4
- const StepExecutionManager_1 = require("./StepExecutionManager");
5
- const switchChain_1 = require("./switchChain");
6
- // Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
7
- const defaultInteractionSettings = {
8
- allowInteraction: true,
9
- allowUpdates: true,
10
- stopExecution: false,
11
- };
12
- class StepExecutor {
13
- constructor(statusManager, settings) {
14
- this.allowUserInteraction = true;
15
- this.executionStopped = false;
16
- this.setInteraction = (settings) => {
17
- const interactionSettings = {
18
- ...defaultInteractionSettings,
19
- ...settings,
20
- };
21
- this.allowUserInteraction = interactionSettings.allowInteraction;
22
- this.stepExecutionManager.allowInteraction(interactionSettings.allowInteraction);
23
- this.statusManager.allowUpdates(interactionSettings.allowUpdates);
24
- this.executionStopped = interactionSettings.stopExecution;
25
- };
26
- // TODO: add checkChain method and update wallet client inside executors
27
- // This can come in handy when we execute multiple routes simultaneously and
28
- // should be sure that we are on the right chain when waiting for transactions.
29
- this.checkChain = () => {
30
- throw new Error('checkChain is not implemented.');
31
- };
32
- this.executeStep = async (walletClient, step) => {
33
- // Make sure that the chain is still correct
34
- // Find if it's bridging and the step is waiting for a transaction on the receiving chain
35
- const recievingChainProcess = step.execution?.process.find((process) => process.type === 'RECEIVING_CHAIN');
36
- // If the step is waiting for a transaction on the receiving chain, we do not switch the chain
37
- // All changes are already done from the source chain
38
- // Return the step
39
- if (recievingChainProcess?.substatus !== 'WAIT_DESTINATION_TRANSACTION' ||
40
- !recievingChainProcess) {
41
- const updatedWalletClient = await (0, switchChain_1.switchChain)(walletClient, this.statusManager, step, this.settings.switchChainHook, this.allowUserInteraction);
42
- if (!updatedWalletClient) {
43
- // Chain switch was not successful, stop execution here
44
- return step;
45
- }
46
- walletClient = updatedWalletClient;
47
- }
48
- const parameters = {
49
- walletClient,
50
- step,
51
- settings: this.settings,
52
- statusManager: this.statusManager,
53
- };
54
- await this.stepExecutionManager.execute(parameters);
55
- return step;
56
- };
57
- this.stepExecutionManager = new StepExecutionManager_1.StepExecutionManager();
58
- this.statusManager = statusManager;
59
- this.settings = settings;
60
- }
61
- }
62
- exports.StepExecutor = StepExecutor;
@@ -1,15 +0,0 @@
1
- import type { WalletClient } from 'viem';
2
- import type { InteractionSettings, InternalExecutionSettings, LifiStep } from '../types';
3
- import type { StatusManager } from './StatusManager';
4
- import { StepExecutionManager } from './StepExecutionManager';
5
- export declare class StepExecutor {
6
- stepExecutionManager: StepExecutionManager;
7
- statusManager: StatusManager;
8
- settings: InternalExecutionSettings;
9
- allowUserInteraction: boolean;
10
- executionStopped: boolean;
11
- constructor(statusManager: StatusManager, settings: InternalExecutionSettings);
12
- setInteraction: (settings?: InteractionSettings) => void;
13
- checkChain: () => never;
14
- executeStep: (walletClient: WalletClient, step: LifiStep) => Promise<LifiStep>;
15
- }