export async function activate()

in src/extension.ts [35:231]


export async function activate(context: ExtensionContext) {
  if (process.env.CODE_TEST) {
    return;
  }

  Constants.initialize(context);
  DebuggerConfiguration.initialize(context);
  await ContractDB.initialize(AdapterType.IN_MEMORY);
  await InfuraServiceClient.initialize(context.globalState);
  MnemonicRepository.initialize(context.globalState);
  TreeManager.initialize(context.globalState);
  TreeService.initialize('AzureBlockchain');
  await sdkCoreCommands.initialize(context.globalState);

  setCommandContext(CommandContext.Enabled, true);
  setCommandContext(CommandContext.IsWorkspaceOpen, isWorkspaceOpen());

  const welcomePage = new WelcomePage(context);
  const requirementsPage = new RequirementsPage(context);
  const changelogPage = new ChangelogPage(context);

  await welcomePage.checkAndShow();
  await changelogPage.checkAndShow();

  //#region azureBlockchain extension commands
  const refresh = commands.registerCommand('azureBlockchainService.refresh', (element) => {
    TreeService.refresh(element);
  });
  const showWelcomePage = commands.registerCommand('azureBlockchainService.showWelcomePage', async () => {
    return welcomePage.show();
  });
  const showRequirementsPage = commands.registerCommand('azureBlockchainService.showRequirementsPage',
    async (checkShowOnStartup: boolean) => {
      return checkShowOnStartup ? await requirementsPage.checkAndShow() : await requirementsPage.show();
    });
  //#endregion

  //#region Ganache extension commands
  const startGanacheServer = commands.registerCommand('azureBlockchainService.startGanacheServer',
    async (viewItem?: ProjectView) => {
      await tryExecute(() => GanacheCommands.startGanacheCmd(viewItem));
    });

  const stopGanacheServer = commands.registerCommand('azureBlockchainService.stopGanacheServer',
    async (viewItem?: ProjectView) => {
      await tryExecute(() => GanacheCommands.stopGanacheCmd(viewItem));
    });
  //#endregion

  //#region truffle commands
  const newSolidityProject = commands.registerCommand('truffle.newSolidityProject', async () => {
    await tryExecute(() => ProjectCommands.newSolidityProject());
  });
  const buildContracts = commands.registerCommand('azureBlockchainService.buildContracts', async () => {
    await tryExecute(() => sdkCoreCommands.build());
  });
  const deployContracts = commands.registerCommand('azureBlockchainService.deployContracts', async () => {
    await tryExecute(() => sdkCoreCommands.deploy());
  });
  const copyByteCode = commands.registerCommand('contract.copyByteCode', async (uri: Uri) => {
    await tryExecute(() => TruffleCommands.writeBytecodeToBuffer(uri));
  });
  const copyDeployedByteCode = commands.registerCommand('contract.copyDeployedByteCode', async (uri: Uri) => {
    await tryExecute(() => TruffleCommands.writeDeployedBytecodeToBuffer(uri));
  });
  const copyABI = commands.registerCommand('contract.copyABI', async (uri: Uri) => {
    await tryExecute(() => TruffleCommands.writeAbiToBuffer(uri));
  });
  const copyRPCEndpointAddress = commands.registerCommand('azureBlockchainService.copyRPCEndpointAddress',
    async (viewItem: NetworkNodeView) => {
      await tryExecute(() => TruffleCommands.writeRPCEndpointAddressToBuffer(viewItem));
    });
  const getPrivateKeyFromMnemonic = commands.registerCommand('azureBlockchainService.getPrivateKey', async () => {
    await tryExecute(() => TruffleCommands.getPrivateKeyFromMnemonic());
  });
  //#endregion

  //#region services with dialog
  const createProject = commands.registerCommand('azureBlockchainService.createProject', async () => {
    await tryExecute(() => ServiceCommands.createProject());
  });
  const connectProject = commands.registerCommand('azureBlockchainService.connectProject', async () => {
    await tryExecute(() => ServiceCommands.connectProject());
  });
  const disconnectProject = commands.registerCommand('azureBlockchainService.disconnectProject',
    async (viewItem: ProjectView) => {
      await tryExecute(() => ServiceCommands.disconnectProject(viewItem));
    });
  const openAtAzurePortal = commands.registerCommand('azureBlockchainService.openAtAzurePortal',
    async (viewItem: NetworkNodeView) => ServiceCommands.openAtAzurePortal(viewItem));
  //#endregion

  //#region Infura commands
  const signInToInfuraAccount = commands.registerCommand('azureBlockchainService.signInToInfuraAccount', async () => {
    await tryExecute(() => InfuraCommands.signIn());
  });
  const signOutOfInfuraAccount = commands.registerCommand('azureBlockchainService.signOutOfInfuraAccount', async () => {
    await tryExecute(() => InfuraCommands.signOut());
  });
  const showProjectsFromInfuraAccount = commands.registerCommand(
    'azureBlockchainService.showProjectsFromInfuraAccount',
    async () => {
      await tryExecute(() => InfuraCommands.showProjectsFromAccount());
    });
  //#endregion

  //#region contract commands
  const createNewBDMApplication = commands.registerCommand('azureBlockchainService.createNewBDMApplication',
    async (viewItem: ProjectView) => {
      await tryExecute(() => ServiceCommands.createNewBDMApplication(viewItem));
    });
  const deleteBDMApplication = commands.registerCommand('azureBlockchainService.deleteBDMApplication',
    async (viewItem: NetworkNodeView) => await tryExecute(() => ServiceCommands.deleteBDMApplication(viewItem)));
  //#endregion

  //#region open zeppelin commands
  const openZeppelinAddCategory = commands.registerCommand('openZeppelin.addCategory', async () => {
    await tryExecute(() => OpenZeppelinCommands.addCategory());
  });
  //#endregion

  //#region logic app commands
  const generateMicroservicesWorkflows = commands.registerCommand(
    'azureBlockchainService.generateMicroservicesWorkflows',
    async (filePath: Uri | undefined) => {
      await tryExecute(async () => await LogicAppCommands.generateMicroservicesWorkflows(filePath));
    });
  const generateDataPublishingWorkflows = commands.registerCommand(
    'azureBlockchainService.generateDataPublishingWorkflows',
    async (filePath: Uri | undefined) => {
      await tryExecute(async () => await LogicAppCommands.generateDataPublishingWorkflows(filePath));
    });
  const generateEventPublishingWorkflows = commands.registerCommand(
    'azureBlockchainService.generateEventPublishingWorkflows',
    async (filePath: Uri | undefined) => {
      await tryExecute(async () => await LogicAppCommands.generateEventPublishingWorkflows(filePath));
    });
  const generateReportPublishingWorkflows = commands.registerCommand(
    'azureBlockchainService.generateReportPublishingWorkflows',
    async (filePath: Uri | undefined) => {
      await tryExecute(async () => await LogicAppCommands.generateReportPublishingWorkflows(filePath));
    });
  //#endregion

  //#region debugger commands
  const startDebugger = commands.registerCommand('extension.truffle.debugTransaction', async () => {
    await tryExecute(() => DebuggerCommands.startSolidityDebugger());
  });
  //#endregion

  //#region other subscriptions
  const changeCoreSdkConfigurationListener = workspace.onDidChangeConfiguration(async (event) => {
    if (event.affectsConfiguration(Constants.userSettings.coreSdkSettingsKey)) {
      await sdkCoreCommands.initialize(context.globalState);
    }
  });
  //#endregion

  const subscriptions = [
    showWelcomePage,
    showRequirementsPage,
    refresh,
    newSolidityProject,
    buildContracts,
    deployContracts,
    createNewBDMApplication,
    createProject,
    connectProject,
    deleteBDMApplication,
    disconnectProject,
    copyByteCode,
    copyDeployedByteCode,
    copyABI,
    copyRPCEndpointAddress,
    startGanacheServer,
    stopGanacheServer,
    generateMicroservicesWorkflows,
    generateDataPublishingWorkflows,
    generateEventPublishingWorkflows,
    generateReportPublishingWorkflows,
    getPrivateKeyFromMnemonic,
    startDebugger,
    signInToInfuraAccount,
    signOutOfInfuraAccount,
    showProjectsFromInfuraAccount,
    openZeppelinAddCategory,
    openAtAzurePortal,
    changeCoreSdkConfigurationListener,
  ];
  context.subscriptions.push(...subscriptions);

  required.checkAllApps();

  Telemetry.sendEvent(Constants.telemetryEvents.extensionActivated);

  checkAndUpgradeOpenZeppelinAsync();
}