UNPKG

@openocean.finance/widget-sdk

Version:

OpenOcean Any-to-Any Cross-Chain-Swap SDK

42 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EVM = EVM; const widget_types_1 = require("@openocean.finance/widget-types"); const viem_1 = require("viem"); const EVMStepExecutor_js_1 = require("./EVMStepExecutor.js"); const getENSAddress_js_1 = require("./getENSAddress.js"); const getEVMBalance_js_1 = require("./getEVMBalance.js"); function EVM(options) { const _options = options ?? {}; return { get type() { return widget_types_1.ChainType.EVM; }, get options() { return _options; }, isAddress: viem_1.isAddress, resolveAddress: getENSAddress_js_1.getENSAddress, getBalance: getEVMBalance_js_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_js_1.EVMStepExecutor({ client: walletClient, routeId: options.routeId, executionOptions: { ...options.executionOptions, switchChainHook: _options.switchChain ?? options.executionOptions?.switchChainHook, }, }); return executor; }, setOptions(options) { Object.assign(_options, options); }, }; } //# sourceMappingURL=EVM.js.map