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

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 (67) hide show
  1. package/dist/LiFi.js +1 -1
  2. package/dist/cjs/LiFi.js +2 -2
  3. package/dist/cjs/connectors.js +3 -6
  4. package/dist/cjs/execution/EVMStepExecutor.js +4 -4
  5. package/dist/cjs/execution/RouteExecutionManager.d.ts +4 -2
  6. package/dist/cjs/execution/RouteExecutionManager.js +10 -8
  7. package/dist/cjs/execution/StepExecutionManager.js +4 -4
  8. package/dist/cjs/execution/multisig.js +2 -5
  9. package/dist/cjs/index.d.ts +2 -0
  10. package/dist/cjs/index.js +5 -2
  11. package/dist/cjs/providers/EVM.d.ts +10 -0
  12. package/dist/cjs/providers/EVM.js +34 -0
  13. package/dist/cjs/providers/Solana.d.ts +9 -0
  14. package/dist/cjs/providers/Solana.js +38 -0
  15. package/dist/cjs/providers/index.d.ts +1 -0
  16. package/dist/cjs/providers/index.js +17 -0
  17. package/dist/cjs/providers/types.d.ts +12 -0
  18. package/dist/cjs/providers/types.js +7 -0
  19. package/dist/cjs/request.js +2 -5
  20. package/dist/cjs/services/ApiService.js +13 -16
  21. package/dist/cjs/services/ChainsService.d.ts +1 -1
  22. package/dist/cjs/services/ChainsService.js +2 -1
  23. package/dist/cjs/services/ConfigService.d.ts +3 -1
  24. package/dist/cjs/services/ConfigService.js +4 -1
  25. package/dist/cjs/types/internal.d.ts +2 -2
  26. package/dist/cjs/utils/parseError.js +3 -6
  27. package/dist/cjs/version.d.ts +1 -1
  28. package/dist/cjs/version.js +1 -1
  29. package/dist/connectors.js +1 -1
  30. package/dist/execution/EVMStepExecutor.js +2 -2
  31. package/dist/execution/RouteExecutionManager.d.ts +4 -2
  32. package/dist/execution/RouteExecutionManager.js +9 -4
  33. package/dist/execution/StepExecutionManager.js +2 -2
  34. package/dist/execution/multisig.js +1 -1
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.js +2 -1
  37. package/dist/providers/EVM.d.ts +10 -0
  38. package/dist/providers/EVM.js +29 -0
  39. package/dist/providers/Solana.d.ts +9 -0
  40. package/dist/providers/Solana.js +33 -0
  41. package/dist/providers/index.d.ts +1 -0
  42. package/dist/providers/index.js +1 -0
  43. package/dist/providers/types.d.ts +12 -0
  44. package/dist/providers/types.js +5 -1
  45. package/dist/request.js +1 -1
  46. package/dist/services/ApiService.js +1 -1
  47. package/dist/services/ChainsService.d.ts +1 -1
  48. package/dist/services/ChainsService.js +1 -1
  49. package/dist/services/ConfigService.d.ts +3 -1
  50. package/dist/services/ConfigService.js +3 -2
  51. package/dist/types/internal.d.ts +2 -2
  52. package/dist/utils/parseError.js +1 -1
  53. package/dist/version.d.ts +1 -1
  54. package/dist/version.js +1 -1
  55. package/package.json +14 -5
  56. package/dist/cjs/providers/BaseProvider.d.ts +0 -7
  57. package/dist/cjs/providers/BaseProvider.js +0 -6
  58. package/dist/cjs/providers/EVMProvider.d.ts +0 -16
  59. package/dist/cjs/providers/EVMProvider.js +0 -28
  60. package/dist/cjs/providers/SolanaProvider.d.ts +0 -15
  61. package/dist/cjs/providers/SolanaProvider.js +0 -32
  62. package/dist/providers/BaseProvider.d.ts +0 -7
  63. package/dist/providers/BaseProvider.js +0 -2
  64. package/dist/providers/EVMProvider.d.ts +0 -16
  65. package/dist/providers/EVMProvider.js +0 -24
  66. package/dist/providers/SolanaProvider.d.ts +0 -15
  67. package/dist/providers/SolanaProvider.js +0 -28
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/sdk';
5
- exports.version = '3.0.0-alpha.7';
5
+ exports.version = '3.0.0-alpha.9';
@@ -1,6 +1,6 @@
1
1
  import { createPublicClient, fallback, http } from 'viem';
2
2
  import * as chains from 'viem/chains'; // TODO: optimize using BE chains
3
- import ConfigService from './services/ConfigService';
3
+ import { ConfigService } from './services/ConfigService';
4
4
  import { ServerError } from './utils/errors';
5
5
  // cached providers
6
6
  const publicClients = {};
@@ -1,7 +1,7 @@
1
1
  import { publicActions } from 'viem';
2
2
  import ApiService from '../services/ApiService';
3
- import ChainsService from '../services/ChainsService';
4
- import ConfigService from '../services/ConfigService';
3
+ import { ChainsService } from '../services/ChainsService';
4
+ import { ConfigService } from '../services/ConfigService';
5
5
  import { getMaxPriorityFeePerGas } from '../utils';
6
6
  import { LiFiErrorCode, TransactionError, ValidationError, } from '../utils/errors';
7
7
  import { getTransactionFailedMessage, parseError } from '../utils/parseError';
@@ -1,12 +1,13 @@
1
1
  import type { Route } from '@lifi/types';
2
- import ConfigService from '../services/ConfigService';
2
+ import type { ProviderType, SDKProvider } from '../providers';
3
+ import { ConfigService } from '../services/ConfigService';
3
4
  import type { SDKOptions } from '../types';
4
5
  import type { ExecutionSettings } from './types';
5
6
  export declare class RouteExecutionManager {
6
7
  private executionDictionary;
7
8
  private executionPromiseDictionary;
8
9
  protected configService: ConfigService;
9
- private providers;
10
+ private providers?;
10
11
  constructor(options: SDKOptions);
11
12
  /**
12
13
  * Execute a route.
@@ -55,4 +56,5 @@ export declare class RouteExecutionManager {
55
56
  * @returns The updated route.
56
57
  */
57
58
  getActiveRoute: (route: Route) => Route | undefined;
59
+ getProvider: (type: ProviderType) => SDKProvider | undefined;
58
60
  }
@@ -1,5 +1,4 @@
1
- import { EVMProvider } from '../providers/EVMProvider';
2
- import ConfigService from '../services/ConfigService';
1
+ import { ConfigService } from '../services/ConfigService';
3
2
  import { ValidationError } from '../utils/errors';
4
3
  import { StatusManager } from './StatusManager';
5
4
  import { prepareRestart } from './prepareRestart';
@@ -85,7 +84,10 @@ export class RouteExecutionManager {
85
84
  step.action.fromAmount = previousStep.execution.toAmount;
86
85
  }
87
86
  try {
88
- const provider = this.providers.find((provider) => provider.isProviderStep(step));
87
+ const provider = this.providers?.find((provider) => provider.isProviderStep(step));
88
+ if (!provider) {
89
+ throw new Error('SDK Execution Provider not found.');
90
+ }
89
91
  const stepExecutor = await provider.getStepExecutor({
90
92
  statusManager,
91
93
  settings: execution.settings,
@@ -188,8 +190,11 @@ export class RouteExecutionManager {
188
190
  this.getActiveRoute = (route) => {
189
191
  return this.executionDictionary[route.id]?.route;
190
192
  };
193
+ this.getProvider = (type) => {
194
+ return this.providers?.find((provider) => provider.type === type);
195
+ };
191
196
  this.configService = ConfigService.getInstance();
192
197
  this.configService.updateConfig(options);
193
- this.providers = options.providers ?? [new EVMProvider()];
198
+ this.providers = options.providers;
194
199
  }
195
200
  }
@@ -1,7 +1,7 @@
1
1
  import { publicActions } from 'viem';
2
2
  import ApiService from '../services/ApiService';
3
- import ChainsService from '../services/ChainsService';
4
- import ConfigService from '../services/ConfigService';
3
+ import { ChainsService } from '../services/ChainsService';
4
+ import { ConfigService } from '../services/ConfigService';
5
5
  import { getMaxPriorityFeePerGas } from '../utils';
6
6
  import { LiFiErrorCode, TransactionError, ValidationError, } from '../utils/errors';
7
7
  import { getTransactionFailedMessage, parseError } from '../utils/parseError';
@@ -1,4 +1,4 @@
1
- import ConfigService from '../services/ConfigService';
1
+ import { ConfigService } from '../services/ConfigService';
2
2
  import { LiFiErrorCode, TransactionError } from '../utils/errors';
3
3
  export const updateMultisigRouteProcess = async (internalTxHash, step, statusManager, processType, fromChain) => {
4
4
  const config = ConfigService.getInstance().getConfig();
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export * from '@lifi/types';
2
2
  export { LiFi } from './LiFi';
3
3
  export * from './execution';
4
4
  export * from './helpers';
5
+ export { EVM, type EVMProviderOptions } from './providers/EVM';
6
+ export { Solana, type SolanaProviderOptions } from './providers/Solana';
5
7
  export * from './types';
6
8
  export * from './utils/errors';
7
9
  export { ErrorCode, LiFiError } from './utils/errors';
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
- // expose types and helpers
2
1
  export * from '@lifi/types';
3
2
  export { LiFi } from './LiFi';
4
3
  export * from './execution';
5
4
  export * from './helpers';
5
+ export { EVM } from './providers/EVM';
6
+ export { Solana } from './providers/Solana';
6
7
  export * from './types';
7
8
  export * from './utils/errors';
8
9
  export { LiFiError } from './utils/errors';
@@ -0,0 +1,10 @@
1
+ import { type WalletClient } from 'viem';
2
+ import type { SDKProvider } from './types';
3
+ export interface EVMProviderOptions {
4
+ getWalletClient: () => Promise<WalletClient>;
5
+ }
6
+ export interface EVMProvider extends SDKProvider {
7
+ setOptions(options: EVMProviderOptions): void;
8
+ }
9
+ export declare function EVM(options?: EVMProviderOptions): EVMProvider;
10
+ export declare function isEVM(provider: SDKProvider): provider is EVMProvider;
@@ -0,0 +1,29 @@
1
+ import { isAddress } from 'viem';
2
+ import { EVMStepExecutor } from '../execution/EVMStepExecutor';
3
+ import { ProviderType } from './types';
4
+ export function EVM(options) {
5
+ let getWalletClient = options?.getWalletClient;
6
+ return {
7
+ get type() {
8
+ return ProviderType.EVM;
9
+ },
10
+ isProviderStep(step) {
11
+ const isProviderStep = isAddress(step.action.fromAddress);
12
+ return isProviderStep;
13
+ },
14
+ async getStepExecutor(options) {
15
+ if (!getWalletClient) {
16
+ throw new Error(`getWalletClient is not provided.`);
17
+ }
18
+ const walletClient = await getWalletClient();
19
+ const executor = new EVMStepExecutor({ walletClient, ...options });
20
+ return executor;
21
+ },
22
+ setOptions(options) {
23
+ getWalletClient = options.getWalletClient;
24
+ },
25
+ };
26
+ }
27
+ export function isEVM(provider) {
28
+ return provider.type === ProviderType.EVM;
29
+ }
@@ -0,0 +1,9 @@
1
+ import type { SDKProvider } from './types';
2
+ export interface SolanaProviderOptions {
3
+ getWalletClient: () => Promise<unknown>;
4
+ }
5
+ export interface SolanaProvider extends SDKProvider {
6
+ setOptions(options: SolanaProviderOptions): void;
7
+ }
8
+ export declare function Solana(options?: SolanaProviderOptions): SolanaProvider;
9
+ export declare function isEVM(provider: SDKProvider): provider is SolanaProvider;
@@ -0,0 +1,33 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import { ProviderType } from './types';
3
+ export function Solana(options) {
4
+ let getWalletClient = options?.getWalletClient;
5
+ return {
6
+ get type() {
7
+ return ProviderType.Solana;
8
+ },
9
+ isProviderStep(step) {
10
+ try {
11
+ const publickKey = new PublicKey(step.action.fromAddress);
12
+ const isProviderStep = PublicKey.isOnCurve(publickKey);
13
+ return isProviderStep;
14
+ }
15
+ catch (error) {
16
+ return false;
17
+ }
18
+ },
19
+ async getStepExecutor(options) {
20
+ if (!getWalletClient) {
21
+ throw new Error(`getWalletClient is not provided.`);
22
+ }
23
+ const walletClient = await getWalletClient();
24
+ return null;
25
+ },
26
+ setOptions(options) {
27
+ getWalletClient = options.getWalletClient;
28
+ },
29
+ };
30
+ }
31
+ export function isEVM(provider) {
32
+ return provider.type === ProviderType.Solana;
33
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,12 @@
1
+ import type { LiFiStep } from '@lifi/types';
2
+ import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
3
+ import type { StepExecutorOptions } from '../execution/types';
4
+ export interface SDKProvider {
5
+ readonly type: ProviderType;
6
+ isProviderStep(step: LiFiStep): boolean;
7
+ getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
8
+ }
9
+ export declare enum ProviderType {
10
+ EVM = "EVM",
11
+ Solana = "Solana"
12
+ }
@@ -1 +1,5 @@
1
- "use strict";
1
+ export var ProviderType;
2
+ (function (ProviderType) {
3
+ ProviderType["EVM"] = "EVM";
4
+ ProviderType["Solana"] = "Solana";
5
+ })(ProviderType || (ProviderType = {}));
package/dist/request.js CHANGED
@@ -1,4 +1,4 @@
1
- import ConfigService from './services/ConfigService';
1
+ import { ConfigService } from './services/ConfigService';
2
2
  import { HTTPError } from './utils/errors';
3
3
  import { wait } from './utils/utils';
4
4
  import { version } from './version';
@@ -2,7 +2,7 @@ import { request } from '../request';
2
2
  import { isRoutesRequest, isStep } from '../typeguards';
3
3
  import { ValidationError } from '../utils/errors';
4
4
  import { parseBackendError } from '../utils/parseError';
5
- import ConfigService from './ConfigService';
5
+ import { ConfigService } from './ConfigService';
6
6
  /**
7
7
  * @param requestConfig
8
8
  * @param options
@@ -1,5 +1,5 @@
1
1
  import type { ChainId, ExtendedChain } from '@lifi/types';
2
- export default class ChainsService {
2
+ export declare class ChainsService {
3
3
  private static instance;
4
4
  private readonly loadingPromise;
5
5
  private chains;
@@ -1,6 +1,6 @@
1
1
  import { ValidationError } from '../utils/errors';
2
2
  import ApiService from './ApiService';
3
- export default class ChainsService {
3
+ export class ChainsService {
4
4
  constructor() {
5
5
  this.chains = [];
6
6
  this.loadingPromise = this.loadAvailableChains();
@@ -1,6 +1,6 @@
1
1
  import type { Chain } from '@lifi/types';
2
2
  import type { SDKConfig, SDKOptions } from '../types';
3
- export default class ConfigService {
3
+ export declare class ConfigService {
4
4
  private static instance;
5
5
  private readonly config;
6
6
  private readonly setupPromise;
@@ -12,11 +12,13 @@ export default class ConfigService {
12
12
  /**
13
13
  * This call immediately returns the current config. It does not make sure that all chain data is already loaded
14
14
  * Use this if you need access to basic information like API urls or settings
15
+ * @returns SDKConfig
15
16
  */
16
17
  getConfig: () => SDKConfig;
17
18
  /**
18
19
  * This call waits for all setup promises to be done.
19
20
  * Use this if you need access to chain data (RPCs or multicalls)
21
+ * @returns SDKConfig
20
22
  */
21
23
  getConfigAsync: () => Promise<SDKConfig>;
22
24
  updateConfig: (configUpdate: Partial<SDKOptions>) => SDKConfig;
@@ -6,12 +6,13 @@ const DefaultExecutionSettings = {
6
6
  infiniteApproval: false,
7
7
  executeInBackground: false,
8
8
  };
9
- class ConfigService {
9
+ export class ConfigService {
10
10
  constructor() {
11
11
  this.resolveSetupPromise = undefined;
12
12
  /**
13
13
  * This call immediately returns the current config. It does not make sure that all chain data is already loaded
14
14
  * Use this if you need access to basic information like API urls or settings
15
+ * @returns SDKConfig
15
16
  */
16
17
  this.getConfig = () => {
17
18
  return this.config;
@@ -19,6 +20,7 @@ class ConfigService {
19
20
  /**
20
21
  * This call waits for all setup promises to be done.
21
22
  * Use this if you need access to chain data (RPCs or multicalls)
23
+ * @returns SDKConfig
22
24
  */
23
25
  this.getConfigAsync = async () => {
24
26
  await this.setupPromise;
@@ -96,4 +98,3 @@ ConfigService.getDefaultConfig = () => {
96
98
  integrator: 'lifi-sdk',
97
99
  };
98
100
  };
99
- export default ConfigService;
@@ -1,6 +1,6 @@
1
1
  import type { ChainId, RouteOptions } from '@lifi/types';
2
2
  import type { ExecutionSettings, InternalExecutionSettings, MultisigConfig } from '../execution/types';
3
- import type { BaseProvider } from '../providers/BaseProvider';
3
+ import type { SDKProvider } from '../providers';
4
4
  export interface SDKConfig {
5
5
  apiUrl: string;
6
6
  apiKey?: string;
@@ -13,7 +13,7 @@ export interface SDKConfig {
13
13
  integrator: string;
14
14
  widgetVersion?: string;
15
15
  multisig?: MultisigConfig;
16
- providers?: BaseProvider[];
16
+ providers?: SDKProvider[];
17
17
  }
18
18
  export interface SDKOptions extends Partial<Omit<SDKConfig, 'defaultExecutionSettings' | 'integrator'>> {
19
19
  defaultExecutionSettings?: ExecutionSettings;
@@ -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.7";
2
+ export declare const version = "3.0.0-alpha.9";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk';
2
- export const version = '3.0.0-alpha.7';
2
+ export const version = '3.0.0-alpha.9';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "3.0.0-alpha.7",
3
+ "version": "3.0.0-alpha.9",
4
4
  "description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
5
5
  "keywords": [
6
6
  "bridge",
@@ -32,9 +32,19 @@
32
32
  },
33
33
  "license": "Apache-2.0",
34
34
  "author": "Max Klenk <max@li.finance>",
35
+ "type": "module",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js",
40
+ "default": "./dist/cjs/index.js"
41
+ },
42
+ "./package.json": "./package.json"
43
+ },
35
44
  "main": "./dist/cjs/index.js",
36
45
  "module": "./dist/index.js",
37
46
  "types": "./dist/index.d.ts",
47
+ "typings": "./dist/index.d.ts",
38
48
  "directories": {
39
49
  "test": "tests"
40
50
  },
@@ -42,9 +52,8 @@
42
52
  "dist"
43
53
  ],
44
54
  "scripts": {
45
- "addscope": "node tools/packagejson name @lifi/sdk",
46
55
  "build": "yarn clean && tsc --project ./tsconfig.json && tsc --project ./tsconfig.cjs.json",
47
- "clean": "node tools/cleanup",
56
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
48
57
  "coverage": "vitest run --coverage",
49
58
  "_postinstall": "husky install",
50
59
  "lint": "eslint --ext .tsx --ext .ts ./src",
@@ -73,10 +82,10 @@
73
82
  ]
74
83
  },
75
84
  "dependencies": {
76
- "@lifi/types": "^9.0.0-alpha.12",
85
+ "@lifi/types": "^9.0.0-alpha.13",
77
86
  "@solana/web3.js": "^1.78.4",
78
87
  "eth-rpc-errors": "^4.0.3",
79
- "viem": "^1.10.3"
88
+ "viem": "^1.10.4"
80
89
  },
81
90
  "devDependencies": {
82
91
  "@commitlint/cli": "^17.7.1",
@@ -1,7 +0,0 @@
1
- import type { LiFiStep } from '@lifi/types';
2
- import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
3
- import type { StepExecutorOptions } from '../execution/types';
4
- export declare abstract class BaseProvider {
5
- abstract isProviderStep(step: LiFiStep): boolean;
6
- abstract getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
7
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseProvider = void 0;
4
- class BaseProvider {
5
- }
6
- exports.BaseProvider = BaseProvider;
@@ -1,16 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EVMProvider = void 0;
4
- const viem_1 = require("viem");
5
- const EVMStepExecutor_1 = require("../execution/EVMStepExecutor");
6
- const BaseProvider_1 = require("./BaseProvider");
7
- class EVMProvider extends BaseProvider_1.BaseProvider {
8
- constructor(options) {
9
- super();
10
- this.getWalletClient = options?.getWalletClient;
11
- }
12
- isProviderStep(step) {
13
- const isProviderStep = (0, viem_1.isAddress)(step.action.fromAddress);
14
- return isProviderStep;
15
- }
16
- async getStepExecutor(options) {
17
- if (!this.getWalletClient) {
18
- throw new Error(`getWalletClient is not provided.`);
19
- }
20
- const walletClient = await this.getWalletClient();
21
- const executor = new EVMStepExecutor_1.EVMStepExecutor({ walletClient, ...options });
22
- return executor;
23
- }
24
- setOptions(options) {
25
- this.getWalletClient = options.getWalletClient;
26
- }
27
- }
28
- exports.EVMProvider = EVMProvider;
@@ -1,15 +0,0 @@
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
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaProvider = void 0;
4
- const web3_js_1 = require("@solana/web3.js");
5
- const BaseProvider_1 = require("./BaseProvider");
6
- class SolanaProvider extends BaseProvider_1.BaseProvider {
7
- constructor(options) {
8
- super();
9
- this.getWalletClient = options?.getWalletClient;
10
- }
11
- isProviderStep(step) {
12
- try {
13
- const publickKey = new web3_js_1.PublicKey(step.action.fromAddress);
14
- const isProviderStep = web3_js_1.PublicKey.isOnCurve(publickKey);
15
- return isProviderStep;
16
- }
17
- catch (error) {
18
- return false;
19
- }
20
- }
21
- async getStepExecutor(options) {
22
- if (!this.getWalletClient) {
23
- throw new Error(`getWalletClient is not provided.`);
24
- }
25
- const walletClient = await this.getWalletClient();
26
- return null;
27
- }
28
- setOptions(options) {
29
- this.getWalletClient = options.getWalletClient;
30
- }
31
- }
32
- exports.SolanaProvider = SolanaProvider;
@@ -1,7 +0,0 @@
1
- import type { LiFiStep } from '@lifi/types';
2
- import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
3
- import type { StepExecutorOptions } from '../execution/types';
4
- export declare abstract class BaseProvider {
5
- abstract isProviderStep(step: LiFiStep): boolean;
6
- abstract getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
7
- }
@@ -1,2 +0,0 @@
1
- export class BaseProvider {
2
- }
@@ -1,16 +0,0 @@
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
- }
@@ -1,24 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
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
- }