(matches: ArgMatches)
| 668 | } |
| 669 | |
| 670 | fn process(matches: ArgMatches) -> Result<(), ValidationError> { |
| 671 | let mut config = DVFConfig::from_matches(&matches)?; |
| 672 | // Check which subcommand was used |
| 673 | match matches.subcommand() { |
| 674 | Some(("init", sub_m)) => { |
| 675 | println!("Starting information gathering. This might take several minutes."); |
| 676 | |
| 677 | let env = *sub_m.get_one::<Environment>("env").unwrap(); |
| 678 | let project = sub_m.value_of("project").unwrap(); |
| 679 | let artifacts = sub_m.value_of("artifacts").unwrap(); |
| 680 | let (path, artifacts_path) = get_project_paths(project, artifacts); |
| 681 | |
| 682 | let mut imp_env = *sub_m.get_one::<Environment>("implementationenv").unwrap(); |
| 683 | let imp_project = sub_m.value_of("implementationproject"); |
| 684 | let imp_artifacts = sub_m.value_of("implementationartifacts").unwrap(); |
| 685 | let imp_path: PathBuf; |
| 686 | let imp_artifacts_path: PathBuf; |
| 687 | if let Some(imp_project) = imp_project { |
| 688 | (imp_path, imp_artifacts_path) = get_project_paths(imp_project, imp_artifacts); |
| 689 | } else { |
| 690 | imp_path = path.clone(); |
| 691 | imp_artifacts_path = artifacts_path.clone(); |
| 692 | imp_env = env |
| 693 | } |
| 694 | |
| 695 | let output_path = Path::new(sub_m.value_of("OUTPUT").unwrap()); |
| 696 | let mut dumped = parse::DumpedDVF::from_cli(sub_m)?; |
| 697 | config.set_chain_id(dumped.chain_id)?; |
| 698 | |
| 699 | let registry = registry::Registry::from_config(&config)?; |
| 700 | let pretty_printer = PrettyPrinter::new(&config, Some(®istry)); |
| 701 | |
| 702 | // Parse optional initblock or take deployment_block_num + 1 |
| 703 | let (deployment_block_num, deployment_tx) = |
| 704 | web3::get_deployment(&config, &dumped.address)?; |
| 705 | info!("Deployment Block: {}", deployment_block_num); |
| 706 | dumped.deployment_block_num = deployment_block_num; |
| 707 | dumped.deployment_tx = deployment_tx; |
| 708 | |
| 709 | let init_block_num = match sub_m.value_of("initblock") { |
| 710 | // This has been validated so we can unwrap here |
| 711 | Some(b) => b.parse::<u64>().unwrap(), |
| 712 | None => deployment_block_num + 1, |
| 713 | }; |
| 714 | dumped.init_block_num = init_block_num; |
| 715 | |
| 716 | let mut pc = 1_u64; |
| 717 | let progress_mode: ProgressMode = match sub_m.value_of("implementation").is_some() { |
| 718 | true => ProgressMode::InitProxy, |
| 719 | false => ProgressMode::Init, |
| 720 | }; |
| 721 | |
| 722 | print_progress("Getting code hash.", &mut pc, &progress_mode); |
| 723 | let rpc_code_hash = web3::get_eth_codehash(&config, &dumped.address, init_block_num)?; |
| 724 | dumped.codehash = rpc_code_hash; |
| 725 | |
| 726 | print_progress("Fetching on-chain bytecode.", &mut pc, &progress_mode); |
| 727 | let rpc_code = web3::get_eth_code(&config, &dumped.address, init_block_num)?; |
no test coverage detected