public static void ResolveEmptyValuesWithDefaults(this ABIConfiguration abiConfiguration, string defaultNamespace, string destinationProjectFolder)
        {
            if (string.IsNullOrEmpty(abiConfiguration.ContractName) && !string.IsNullOrEmpty(abiConfiguration.ABIFile))
            {
                abiConfiguration.ContractName = Path.GetFileNameWithoutExtension(abiConfiguration.ABIFile);
            }

            if (string.IsNullOrEmpty(abiConfiguration.ABI))
            {
                abiConfiguration.ABI = GetFileContent(destinationProjectFolder, abiConfiguration.ABIFile);
            }

            //by convention - look for bin folder in the same place as the abi
            if (string.IsNullOrEmpty(abiConfiguration.BinFile) && !string.IsNullOrEmpty(abiConfiguration.ABIFile))
            {
                if (abiConfiguration.ABIFile.EndsWith(".abi", StringComparison.InvariantCultureIgnoreCase))
                {
                    abiConfiguration.BinFile = $"{abiConfiguration.ABIFile.Substring(0, abiConfiguration.ABIFile.Length - 4)}.bin";
                }
            }

            if (string.IsNullOrEmpty(abiConfiguration.ByteCode) && !string.IsNullOrEmpty(abiConfiguration.BinFile))
            {
                abiConfiguration.ByteCode = GetFileContent(destinationProjectFolder, abiConfiguration.BinFile);
            }

            //no bytecode so clear bin file
            if (string.IsNullOrEmpty(abiConfiguration.ByteCode))
            {
                abiConfiguration.BinFile = null;
            }

            if (string.IsNullOrEmpty(abiConfiguration.BaseOutputPath))
            {
                abiConfiguration.BaseOutputPath = destinationProjectFolder;
            }

            if (string.IsNullOrEmpty(abiConfiguration.BaseNamespace))
            {
                abiConfiguration.BaseNamespace = defaultNamespace;
            }

            if (string.IsNullOrEmpty(abiConfiguration.CQSNamespace))
            {
                abiConfiguration.CQSNamespace = $"{abiConfiguration.ContractName}.CQS";
            }

            if (string.IsNullOrEmpty(abiConfiguration.DTONamespace))
            {
                abiConfiguration.DTONamespace = $"{abiConfiguration.ContractName}.DTO";
            }

            if (string.IsNullOrEmpty(abiConfiguration.ServiceNamespace))
            {
                abiConfiguration.ServiceNamespace = $"{abiConfiguration.ContractName}.Service";
            }
        }
        private static ABIConfiguration CreateAbiConfiguration(string abiFile, string projectFolder, string projectName, string assemblyName, CodeGenLanguage language)
        {
            var contractName = Path.GetFileNameWithoutExtension(abiFile);

            var binFileName = Path.Combine(Path.GetDirectoryName(abiFile), contractName + ".bin");
            var byteCode    = File.Exists(binFileName) ? File.ReadAllText(binFileName) : string.Empty;

            var abiConfig = new ABIConfiguration
            {
                CodeGenLanguage = language,
                ABI             = File.ReadAllText(abiFile),
                ByteCode        = byteCode,
                ContractName    = contractName
            };

            var defaultNamespace = GeneratorConfigurationUtils.CreateNamespaceFromAssemblyName(assemblyName);

            abiConfig.ResolveEmptyValuesWithDefaults(defaultNamespace, projectFolder);
            return(abiConfig);
        }
        public GeneratorConfiguration FromAbi(string contractName, string abiFilePath, string binFilePath, string baseNamespace, string outputFolder)
        {
            var config = new GeneratorConfiguration();

            var abi = GeneratorConfigurationUtils.GetFileContent(outputFolder, abiFilePath);

            if (string.IsNullOrEmpty(abi))
            {
                throw new ArgumentException("Could not find abi file or abi content is empty");
            }

            if (string.IsNullOrEmpty(binFilePath))
            {
                binFilePath = abiFilePath.Replace(".abi", ".bin");
            }

            var byteCode = GeneratorConfigurationUtils.GetFileContent(outputFolder, binFilePath);

            if (string.IsNullOrEmpty(contractName))
            {
                contractName = Path.GetFileNameWithoutExtension(abiFilePath);
            }

            var abiConfig = new ABIConfiguration
            {
                ABI          = abi,
                ByteCode     = byteCode,
                ContractName = contractName
            };

            abiConfig.ResolveEmptyValuesWithDefaults(baseNamespace, outputFolder);

            config.ABIConfigurations = new List <ABIConfiguration>();
            config.ABIConfigurations.Add(abiConfig);
            return(config);
        }