@openocean.finance/widget-sdk
Version:
OpenOcean Any-to-Any Cross-Chain-Swap SDK
39 lines • 1.36 kB
JavaScript
import { ChainType } from '@openocean.finance/widget-types';
import { isAddress } from 'viem';
import { EVMStepExecutor } from './EVMStepExecutor.js';
import { getENSAddress } from './getENSAddress.js';
import { getEVMBalance } from './getEVMBalance.js';
export function EVM(options) {
const _options = options ?? {};
return {
get type() {
return ChainType.EVM;
},
get options() {
return _options;
},
isAddress,
resolveAddress: getENSAddress,
getBalance: 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({
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