import { EtherspotBundler, ModularSdk, MODULE_TYPE, sleep } from '@etherspot/modular-sdk';
import * as dotenv from 'dotenv';

dotenv.config();

async function main() {
  const bundlerApiKey = process.env.API_KEY;

  // initializating sdk...
  const modularSdk = new ModularSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, 
                                    { 
                                      chainId: Number(process.env.CHAIN_ID),
                                      bundlerProvider: new EtherspotBundler(Number(process.env.CHAIN_ID),
                                      bundlerApiKey) 
                                    });

  console.log('address: ', modularSdk.state.EOAAddress);

  // get address of EtherspotWallet
  const address: string = await modularSdk.getCounterFactualAddress();

  console.log('\x1b[33m%s\x1b[0m', `EtherspotWallet address: ${address}`);

  const moduleAddress = '';

  const previousAddress = await modularSdk.getPreviousAddress(MODULE_TYPE.VALIDATOR, moduleAddress);
  console.log(`previousAddress: ${previousAddress}`);
}

main()
  .catch(console.error)
  .finally(() => process.exit());