@lifi/sdk 3.0.0-alpha.6 → 3.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/LiFi.d.ts +21 -18
  2. package/dist/LiFi.js +16 -13
  3. package/dist/allowance/setAllowance.d.ts +1 -1
  4. package/dist/cjs/LiFi.d.ts +21 -18
  5. package/dist/cjs/LiFi.js +17 -14
  6. package/dist/cjs/allowance/setAllowance.d.ts +1 -1
  7. package/dist/cjs/connectors.d.ts +1 -1
  8. package/dist/cjs/connectors.js +3 -6
  9. package/dist/cjs/execution/BaseStepExecutor.d.ts +12 -0
  10. package/dist/cjs/execution/BaseStepExecutor.js +27 -0
  11. package/dist/cjs/execution/EVMStepExecutor.d.ts +13 -0
  12. package/dist/cjs/execution/EVMStepExecutor.js +292 -0
  13. package/dist/cjs/execution/RouteExecutionManager.d.ts +9 -8
  14. package/dist/cjs/execution/RouteExecutionManager.js +26 -24
  15. package/dist/cjs/execution/StatusManager.d.ts +8 -7
  16. package/dist/cjs/execution/StatusManager.js +1 -1
  17. package/dist/cjs/execution/StepExecutionManager.d.ts +3 -3
  18. package/dist/cjs/execution/StepExecutionManager.js +8 -8
  19. package/dist/cjs/execution/checkAllowance.d.ts +3 -2
  20. package/dist/cjs/execution/checkBalance.d.ts +2 -2
  21. package/dist/cjs/execution/index.d.ts +1 -0
  22. package/dist/cjs/execution/index.js +1 -0
  23. package/dist/cjs/execution/multisig.d.ts +2 -2
  24. package/dist/cjs/execution/multisig.js +2 -5
  25. package/dist/cjs/execution/prepareRestart.d.ts +2 -3
  26. package/dist/cjs/execution/prepareRestart.js +2 -2
  27. package/dist/cjs/execution/stepComparison.d.ts +4 -3
  28. package/dist/cjs/execution/stepComparison.js +1 -1
  29. package/dist/cjs/execution/switchChain.d.ts +4 -3
  30. package/dist/cjs/execution/switchChain.js +1 -0
  31. package/dist/cjs/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
  32. package/dist/cjs/execution/utils.d.ts +2 -2
  33. package/dist/cjs/execution/waitForReceivingTransaction.d.ts +3 -3
  34. package/dist/cjs/helpers.d.ts +2 -2
  35. package/dist/cjs/index.d.ts +5 -1
  36. package/dist/cjs/index.js +10 -4
  37. package/dist/cjs/providers/EVM.d.ts +10 -0
  38. package/dist/cjs/providers/EVM.js +34 -0
  39. package/dist/cjs/providers/Solana.d.ts +9 -0
  40. package/dist/cjs/providers/Solana.js +38 -0
  41. package/dist/cjs/providers/index.d.ts +1 -0
  42. package/dist/cjs/providers/index.js +17 -0
  43. package/dist/cjs/providers/types.d.ts +12 -0
  44. package/dist/cjs/providers/types.js +8 -0
  45. package/dist/cjs/request.js +12 -9
  46. package/dist/cjs/services/ApiService.d.ts +4 -5
  47. package/dist/cjs/services/ApiService.js +15 -18
  48. package/dist/cjs/services/ChainsService.d.ts +1 -1
  49. package/dist/cjs/services/ChainsService.js +2 -1
  50. package/dist/cjs/services/ConfigService.d.ts +9 -6
  51. package/dist/cjs/services/ConfigService.js +7 -4
  52. package/dist/cjs/typeguards.d.ts +2 -2
  53. package/dist/cjs/types/index.d.ts +1 -3
  54. package/dist/cjs/types/index.js +1 -5
  55. package/dist/cjs/types/internal.d.ts +60 -0
  56. package/dist/cjs/types/internal.js +2 -0
  57. package/dist/cjs/utils/parseError.d.ts +4 -4
  58. package/dist/cjs/utils/parseError.js +3 -6
  59. package/dist/cjs/version.d.ts +1 -1
  60. package/dist/cjs/version.js +1 -1
  61. package/dist/connectors.d.ts +1 -1
  62. package/dist/connectors.js +1 -1
  63. package/dist/execution/BaseStepExecutor.d.ts +12 -0
  64. package/dist/execution/BaseStepExecutor.js +23 -0
  65. package/dist/execution/EVMStepExecutor.d.ts +13 -0
  66. package/dist/execution/EVMStepExecutor.js +285 -0
  67. package/dist/execution/RouteExecutionManager.d.ts +9 -8
  68. package/dist/execution/RouteExecutionManager.js +25 -20
  69. package/dist/execution/StatusManager.d.ts +8 -7
  70. package/dist/execution/StatusManager.js +1 -1
  71. package/dist/execution/StepExecutionManager.d.ts +3 -3
  72. package/dist/execution/StepExecutionManager.js +6 -6
  73. package/dist/execution/checkAllowance.d.ts +3 -2
  74. package/dist/execution/checkBalance.d.ts +2 -2
  75. package/dist/execution/index.d.ts +1 -0
  76. package/dist/execution/index.js +1 -0
  77. package/dist/execution/multisig.d.ts +2 -2
  78. package/dist/execution/multisig.js +1 -1
  79. package/dist/execution/prepareRestart.d.ts +2 -3
  80. package/dist/execution/prepareRestart.js +2 -2
  81. package/dist/execution/stepComparison.d.ts +4 -3
  82. package/dist/execution/stepComparison.js +1 -1
  83. package/dist/execution/switchChain.d.ts +4 -3
  84. package/dist/execution/switchChain.js +1 -0
  85. package/dist/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
  86. package/dist/execution/utils.d.ts +2 -2
  87. package/dist/execution/waitForReceivingTransaction.d.ts +3 -3
  88. package/dist/helpers.d.ts +2 -2
  89. package/dist/index.d.ts +5 -1
  90. package/dist/index.js +5 -2
  91. package/dist/providers/EVM.d.ts +10 -0
  92. package/dist/providers/EVM.js +29 -0
  93. package/dist/providers/Solana.d.ts +9 -0
  94. package/dist/providers/Solana.js +33 -0
  95. package/dist/providers/index.d.ts +1 -0
  96. package/dist/providers/index.js +1 -0
  97. package/dist/providers/types.d.ts +12 -0
  98. package/dist/providers/types.js +5 -0
  99. package/dist/request.js +12 -6
  100. package/dist/services/ApiService.d.ts +4 -5
  101. package/dist/services/ApiService.js +3 -3
  102. package/dist/services/ChainsService.d.ts +1 -1
  103. package/dist/services/ChainsService.js +1 -1
  104. package/dist/services/ConfigService.d.ts +9 -6
  105. package/dist/services/ConfigService.js +6 -5
  106. package/dist/typeguards.d.ts +2 -2
  107. package/dist/types/index.d.ts +1 -3
  108. package/dist/types/index.js +1 -3
  109. package/dist/types/internal.d.ts +60 -0
  110. package/dist/types/internal.js +1 -0
  111. package/dist/utils/parseError.d.ts +4 -4
  112. package/dist/utils/parseError.js +1 -1
  113. package/dist/version.d.ts +1 -1
  114. package/dist/version.js +1 -1
  115. package/package.json +6 -5
  116. package/dist/cjs/execution/StepExecutor.d.ts +0 -15
  117. package/dist/cjs/execution/StepExecutor.js +0 -62
  118. package/dist/execution/StepExecutor.d.ts +0 -15
  119. package/dist/execution/StepExecutor.js +0 -58
  120. /package/dist/cjs/{types/internal.types.js → execution/types.js} +0 -0
  121. /package/dist/{types/internal.types.js → execution/types.js} +0 -0
@@ -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>;
@@ -1,7 +1,7 @@
1
1
  import { errorCodes as MetaMaskErrorCodes, getMessageFromCode, } from 'eth-rpc-errors';
2
2
  import { formatUnits } from 'viem';
3
3
  import { fetchTxErrorDetails } from '../helpers';
4
- import ChainsService from '../services/ChainsService';
4
+ import { ChainsService } from '../services/ChainsService';
5
5
  import { ErrorMessage, EthersErrorMessage, EthersErrorType, LiFiError, LiFiErrorCode, MetaMaskProviderErrorCode, NotFoundError, ProviderError, RPCError, ServerError, SlippageError, TransactionError, UnknownError, ValidationError, } from './errors';
6
6
  /**
7
7
  * Available MetaMask error codes:
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.6";
2
+ export declare const version = "3.0.0-alpha.8";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk';
2
- export const version = '3.0.0-alpha.6';
2
+ export const version = '3.0.0-alpha.8';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "3.0.0-alpha.6",
3
+ "version": "3.0.0-alpha.8",
4
4
  "description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
5
5
  "keywords": [
6
6
  "bridge",
@@ -73,17 +73,18 @@
73
73
  ]
74
74
  },
75
75
  "dependencies": {
76
- "@lifi/types": "^9.0.0-alpha.11",
76
+ "@lifi/types": "^9.0.0-alpha.12",
77
+ "@solana/web3.js": "^1.78.4",
77
78
  "eth-rpc-errors": "^4.0.3",
78
- "viem": "^1.9.2"
79
+ "viem": "^1.10.3"
79
80
  },
80
81
  "devDependencies": {
81
82
  "@commitlint/cli": "^17.7.1",
82
83
  "@commitlint/config-conventional": "^17.7.0",
83
84
  "@mswjs/interceptors": "^0.22.16",
84
85
  "@types/ws": "^8.5.5",
85
- "@typescript-eslint/eslint-plugin": "^6.5.0",
86
- "@typescript-eslint/parser": "^6.5.0",
86
+ "@typescript-eslint/eslint-plugin": "^6.6.0",
87
+ "@typescript-eslint/parser": "^6.6.0",
87
88
  "@vitest/coverage-v8": "^0.34.3",
88
89
  "cross-fetch": "^4.0.0",
89
90
  "eslint": "^8.48.0",
@@ -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
- }
@@ -1,58 +0,0 @@
1
- import { StepExecutionManager } from './StepExecutionManager';
2
- import { switchChain } from './switchChain';
3
- // Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
4
- const defaultInteractionSettings = {
5
- allowInteraction: true,
6
- allowUpdates: true,
7
- stopExecution: false,
8
- };
9
- export class StepExecutor {
10
- constructor(statusManager, settings) {
11
- this.allowUserInteraction = true;
12
- this.executionStopped = false;
13
- this.setInteraction = (settings) => {
14
- const interactionSettings = {
15
- ...defaultInteractionSettings,
16
- ...settings,
17
- };
18
- this.allowUserInteraction = interactionSettings.allowInteraction;
19
- this.stepExecutionManager.allowInteraction(interactionSettings.allowInteraction);
20
- this.statusManager.allowUpdates(interactionSettings.allowUpdates);
21
- this.executionStopped = interactionSettings.stopExecution;
22
- };
23
- // TODO: add checkChain method and update wallet client inside executors
24
- // This can come in handy when we execute multiple routes simultaneously and
25
- // should be sure that we are on the right chain when waiting for transactions.
26
- this.checkChain = () => {
27
- throw new Error('checkChain is not implemented.');
28
- };
29
- this.executeStep = async (walletClient, step) => {
30
- // Make sure that the chain is still correct
31
- // Find if it's bridging and the step is waiting for a transaction on the receiving chain
32
- const recievingChainProcess = step.execution?.process.find((process) => process.type === 'RECEIVING_CHAIN');
33
- // If the step is waiting for a transaction on the receiving chain, we do not switch the chain
34
- // All changes are already done from the source chain
35
- // Return the step
36
- if (recievingChainProcess?.substatus !== 'WAIT_DESTINATION_TRANSACTION' ||
37
- !recievingChainProcess) {
38
- const updatedWalletClient = await switchChain(walletClient, this.statusManager, step, this.settings.switchChainHook, this.allowUserInteraction);
39
- if (!updatedWalletClient) {
40
- // Chain switch was not successful, stop execution here
41
- return step;
42
- }
43
- walletClient = updatedWalletClient;
44
- }
45
- const parameters = {
46
- walletClient,
47
- step,
48
- settings: this.settings,
49
- statusManager: this.statusManager,
50
- };
51
- await this.stepExecutionManager.execute(parameters);
52
- return step;
53
- };
54
- this.stepExecutionManager = new StepExecutionManager();
55
- this.statusManager = statusManager;
56
- this.settings = settings;
57
- }
58
- }