UNPKG

@getclave/lifi-sdk

Version:

LI.FI Any-to-Any Cross-Chain-Swap SDK

42 lines (41 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EVM = EVM; const types_1 = require("@lifi/types"); const viem_1 = require("viem"); const EVMStepExecutor_1 = require("./EVMStepExecutor"); const getENSAddress_1 = require("./getENSAddress"); const getEVMBalance_1 = require("./getEVMBalance"); function EVM(options) { const _options = options ?? {}; return { get type() { return types_1.ChainType.EVM; }, get options() { return _options; }, isAddress: viem_1.isAddress, resolveAddress: getENSAddress_1.getENSAddress, getBalance: getEVMBalance_1.getEVMBalance, getWalletClient: _options.getWalletClient, async getStepExecutor(options) { if (!_options.getWalletClient) { throw new Error('Client is not provided.'); } const walletClient = await _options.getWalletClient(); const executor = new EVMStepExecutor_1.EVMStepExecutor({ client: walletClient, routeId: options.routeId, executionOptions: { ...options.executionOptions, switchChainHook: _options.switchChain ?? options.executionOptions?.switchChainHook, }, }); return executor; }, setOptions(options) { Object.assign(_options, options); }, }; }